# 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
  object
  ControllerBase
  ApplicationController

Inherited Members
  ControllerBase.StatusCode(int)
  ControllerBase.StatusCode(int, object)
  ControllerBase.Content(string)
  ControllerBase.Content(string, string)
  ControllerBase.Content(string, string, Encoding)
  ControllerBase.Content(string, MediaTypeHeaderValue)
  ControllerBase.NoContent()
  ControllerBase.Ok()
  ControllerBase.Ok(object)
  ControllerBase.Redirect(string)
  ControllerBase.RedirectPermanent(string)
  ControllerBase.RedirectPreserveMethod(string)
  ControllerBase.RedirectPermanentPreserveMethod(string)
  ControllerBase.LocalRedirect(string)
  ControllerBase.LocalRedirectPermanent(string)
  ControllerBase.LocalRedirectPreserveMethod(string)
  ControllerBase.LocalRedirectPermanentPreserveMethod(string)
  ControllerBase.RedirectToAction()
  ControllerBase.RedirectToAction(string)
  ControllerBase.RedirectToAction(string, object)
  ControllerBase.RedirectToAction(string, string)
  ControllerBase.RedirectToAction(string, string, object)
  ControllerBase.RedirectToAction(string, string, string)
  ControllerBase.RedirectToAction(string, string, object, string)
  ControllerBase.RedirectToActionPreserveMethod(string, string, object, string)
  ControllerBase.RedirectToActionPermanent(string)
  ControllerBase.RedirectToActionPermanent(string, object)
  ControllerBase.RedirectToActionPermanent(string, string)
  ControllerBase.RedirectToActionPermanent(string, string, string)
  ControllerBase.RedirectToActionPermanent(string, string, object)
  ControllerBase.RedirectToActionPermanent(string, string, object, string)
  ControllerBase.RedirectToActionPermanentPreserveMethod(string, string, object, string)
  ControllerBase.RedirectToRoute(string)
  ControllerBase.RedirectToRoute(object)
  ControllerBase.RedirectToRoute(string, object)
  ControllerBase.RedirectToRoute(string, string)
  ControllerBase.RedirectToRoute(string, object, string)
  ControllerBase.RedirectToRoutePreserveMethod(string, object, string)
  ControllerBase.RedirectToRoutePermanent(string)
  ControllerBase.RedirectToRoutePermanent(object)
  ControllerBase.RedirectToRoutePermanent(string, object)
  ControllerBase.RedirectToRoutePermanent(string, string)
  ControllerBase.RedirectToRoutePermanent(string, object, string)
  ControllerBase.RedirectToRoutePermanentPreserveMethod(string, object, string)
  ControllerBase.RedirectToPage(string)
  ControllerBase.RedirectToPage(string, object)
  ControllerBase.RedirectToPage(string, string)
  ControllerBase.RedirectToPage(string, string, object)
  ControllerBase.RedirectToPage(string, string, string)
  ControllerBase.RedirectToPage(string, string, object, string)
  ControllerBase.RedirectToPagePermanent(string)
  ControllerBase.RedirectToPagePermanent(string, object)
  ControllerBase.RedirectToPagePermanent(string, string)
  ControllerBase.RedirectToPagePermanent(string, string, string)
  ControllerBase.RedirectToPagePermanent(string, string, object, string)
  ControllerBase.RedirectToPagePreserveMethod(string, string, object, string)
  ControllerBase.RedirectToPagePermanentPreserveMethod(string, string, object, string)
  ControllerBase.File(byte[], string)
  ControllerBase.File(byte[], string, bool)
  ControllerBase.File(byte[], string, string)
  ControllerBase.File(byte[], string, string, bool)
  ControllerBase.File(byte[], string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(byte[], string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.File(byte[], string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(byte[], string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.File(Stream, string)
  ControllerBase.File(Stream, string, bool)
  ControllerBase.File(Stream, string, string)
  ControllerBase.File(Stream, string, string, bool)
  ControllerBase.File(Stream, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(Stream, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.File(Stream, string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(Stream, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.File(string, string)
  ControllerBase.File(string, string, bool)
  ControllerBase.File(string, string, string)
  ControllerBase.File(string, string, string, bool)
  ControllerBase.File(string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.File(string, string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.File(string, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.PhysicalFile(string, string)
  ControllerBase.PhysicalFile(string, string, bool)
  ControllerBase.PhysicalFile(string, string, string)
  ControllerBase.PhysicalFile(string, string, string, bool)
  ControllerBase.PhysicalFile(string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.PhysicalFile(string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.PhysicalFile(string, string, string, DateTimeOffset?, EntityTagHeaderValue)
  ControllerBase.PhysicalFile(string, string, string, DateTimeOffset?, EntityTagHeaderValue, bool)
  ControllerBase.Unauthorized()
  ControllerBase.Unauthorized(object)
  ControllerBase.NotFound()
  ControllerBase.NotFound(object)
  ControllerBase.BadRequest()
  ControllerBase.BadRequest(object)
  ControllerBase.BadRequest(ModelStateDictionary)
  ControllerBase.UnprocessableEntity()
  ControllerBase.UnprocessableEntity(object)
  ControllerBase.UnprocessableEntity(ModelStateDictionary)
  ControllerBase.Conflict()
  ControllerBase.Conflict(object)
  ControllerBase.Conflict(ModelStateDictionary)
  ControllerBase.Problem(string, string, int?, string, string)
  ControllerBase.ValidationProblem(ValidationProblemDetails)
  ControllerBase.ValidationProblem(ModelStateDictionary)
  ControllerBase.ValidationProblem()
  ControllerBase.ValidationProblem(string, string, int?, string, string, ModelStateDictionary)
  ControllerBase.Created()
  ControllerBase.Created(string, object)
  ControllerBase.Created(Uri, object)
  ControllerBase.CreatedAtAction(string, object)
  ControllerBase.CreatedAtAction(string, object, object)
  ControllerBase.CreatedAtAction(string, string, object, object)
  ControllerBase.CreatedAtRoute(string, object)
  ControllerBase.CreatedAtRoute(object, object)
  ControllerBase.CreatedAtRoute(string, object, object)
  ControllerBase.Accepted()
  ControllerBase.Accepted(object)
  ControllerBase.Accepted(Uri)
  ControllerBase.Accepted(string)
  ControllerBase.Accepted(string, object)
  ControllerBase.Accepted(Uri, object)
  ControllerBase.AcceptedAtAction(string)
  ControllerBase.AcceptedAtAction(string, string)
  ControllerBase.AcceptedAtAction(string, object)
  ControllerBase.AcceptedAtAction(string, string, object)
  ControllerBase.AcceptedAtAction(string, object, object)
  ControllerBase.AcceptedAtAction(string, string, object, object)
  ControllerBase.AcceptedAtRoute(object)
  ControllerBase.AcceptedAtRoute(string)
  ControllerBase.AcceptedAtRoute(string, object)
  ControllerBase.AcceptedAtRoute(object, object)
  ControllerBase.AcceptedAtRoute(string, object, object)
  ControllerBase.Challenge()
  ControllerBase.Challenge(params string[])
  ControllerBase.Challenge(AuthenticationProperties)
  ControllerBase.Challenge(AuthenticationProperties, params string[])
  ControllerBase.Forbid()
  ControllerBase.Forbid(params string[])
  ControllerBase.Forbid(AuthenticationProperties)
  ControllerBase.Forbid(AuthenticationProperties, params string[])
  ControllerBase.SignIn(ClaimsPrincipal)
  ControllerBase.SignIn(ClaimsPrincipal, string)
  ControllerBase.SignIn(ClaimsPrincipal, AuthenticationProperties)
  ControllerBase.SignIn(ClaimsPrincipal, AuthenticationProperties, string)
  ControllerBase.SignOut()
  ControllerBase.SignOut(AuthenticationProperties)
  ControllerBase.SignOut(params string[])
  ControllerBase.SignOut(AuthenticationProperties, params string[])
  ControllerBase.TryUpdateModelAsync<TModel>(TModel)
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string)
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider)
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, params Expression<Func<TModel, object>>[])
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, Func<ModelMetadata, bool>)
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider, params Expression<Func<TModel, object>>[])
  ControllerBase.TryUpdateModelAsync<TModel>(TModel, string, IValueProvider, Func<ModelMetadata, bool>)
  ControllerBase.TryUpdateModelAsync(object, Type, string)
  ControllerBase.TryUpdateModelAsync(object, Type, string, IValueProvider, Func<ModelMetadata, bool>)
  ControllerBase.TryValidateModel(object)
  ControllerBase.TryValidateModel(object, string)
  ControllerBase.HttpContext
  ControllerBase.Request
  ControllerBase.Response
  ControllerBase.RouteData
  ControllerBase.ModelState
  ControllerBase.ControllerContext
  ControllerBase.MetadataProvider
  ControllerBase.ModelBinderFactory
  ControllerBase.Url
  ControllerBase.ObjectValidator
  ControllerBase.ProblemDetailsFactory
  ControllerBase.User
  ControllerBase.Empty
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## 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.