Table of Contents

Class ApplicationController

Namespace
adas_core.Controllers
Assembly
adas-core.dll

Provides API endpoints for managing application-level operations such as subscribers, file uploads, asset management, and cache cleaning.

[Route("application")]
[ApiController]
public class ApplicationController : ControllerBase
Inheritance
ApplicationController
Inherited Members
Extension Methods

Constructors

ApplicationController(IFileService, ISubscribersService, ISubscriberGroupedService, IClientMessageService, ICacheService?)

Initializes a new instance of the ApplicationController class with the required services.

public ApplicationController(IFileService fileService, ISubscribersService subscribersService, ISubscriberGroupedService subscriberGroupedService, IClientMessageService clientMessageService, ICacheService? redisService)

Parameters

fileService IFileService

The service responsible for handling file operations.

subscribersService ISubscribersService

The service responsible for managing subscribers.

subscriberGroupedService ISubscriberGroupedService

The service responsible for managing grouped subscribers.

clientMessageService IClientMessageService

The service responsible for handling client messages.

redisService ICacheService

The optional cache service used for distributed caching. May be null if caching is not configured.

Exceptions

ArgumentNullException

Thrown when fileService, subscribersService, subscriberGroupedService, or clientMessageService is null.

Methods

CleanCache()

Cleans the Redis cache. Restricted to users with AuthAdmin permissions.

[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
[HttpGet("cleaning")]
public ActionResult CleanCache()

Returns

ActionResult

An ActionResult containing an HTTP 200 OK response when the cache is successfully cleared.

Exceptions

InvalidFormatException

Thrown when the Redis service is not available.

GetSubscribersGroup()

Handles an anonymous HTTP GET request to retrieve the list of subscribers grouped according to the application's grouping rules. The grouped result is obtained from the subscriber grouping service and returned with an HTTP 200 OK status.

[HttpGet("subscribers-group")]
[AllowAnonymous]
public IActionResult GetSubscribersGroup()

Returns

IActionResult

An IActionResult containing the grouped subscribers returned by the subscriber grouping service wrapped in an HTTP 200 OK response.

GetSubscribersVersion()

Handles an anonymous HTTP GET request to retrieve the list of subscribers by delegating to the subscribers service and returning the result.

[HttpGet("subscribers")]
[AllowAnonymous]
public IActionResult GetSubscribersVersion()

Returns

IActionResult

An IActionResult containing the subscribers data returned by _subscribersService.GetSubscribers().

UGetAssetFile(string)

Retrieves all asset files for the specified theme, restricted to users with the AuthAdmin role. Validates the theme by attempting to parse it into an FileEnum.AssetTheme value; an invalid theme results in an InvalidFormatException.

[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
[HttpGet("{theme}/{category}/asset")]
public ActionResult UGetAssetFile(string theme)

Parameters

theme string

The theme name to parse into an FileEnum.AssetTheme value used to look up the associated asset files.

Returns

ActionResult

An ActionResult containing the list of asset files for the resolved theme.

Exceptions

InvalidFormatException

Thrown when the theme parameter cannot be parsed into a valid FileEnum.AssetTheme value.

UpdateApplications(List<PatientLocation>)

Sends an update message containing the provided patient location data to the relevant boxes.

[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
[HttpPost]
public IActionResult UpdateApplications(List<PatientLocation> boxes)

Parameters

boxes List<PatientLocation>

The list of patient locations to be dispatched to the boxes for update.

Returns

IActionResult

An IActionResult containing an HTTP 200 OK response when the update messages are successfully dispatched.

UploadAssetFile(string, List<IFormFile>)

Uploads one or more asset files to the storage associated with the specified theme. Requires AuthAdmin permissions and enforces a maximum request size of 300 MB. If the supplied theme does not match a valid FileEnum.AssetTheme value, the request is rejected as a bad request with an invalid format error.

[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
[HttpPost("upload/{theme}/{category}/asset")]
[RequestSizeLimit(300000000)]
public Task<ActionResult> UploadAssetFile(string theme, List<IFormFile> files)

Parameters

theme string

The asset theme name; must be parseable to a FileEnum.AssetTheme value.

files List<IFormFile>

The collection of files to upload to the resolved theme.

Returns

Task<ActionResult>

An ActionResult containing an HTTP 200 OK response when the files are successfully uploaded.

Exceptions

InvalidFormatException

Thrown when the provided theme cannot be parsed into a valid FileEnum.AssetTheme value.

UploadFile(List<IFormFile>)

Handles uploading files by delegating to the file service, which copies and updates the provided files. Restricted to users with the AuthAdmin role and accepts requests up to 300,000,000 bytes in size.

[AuthorizeRoles(PermissionEnum.RolesType.AuthAdmin)]
[HttpPost("upload")]
[RequestSizeLimit(300000000)]
public Task<ActionResult> UploadFile(List<IFormFile> files)

Parameters

files List<IFormFile>

The list of files submitted for upload.

Returns

Task<ActionResult>

An ActionResult indicating the result of the upload operation.