# Class UnitController

Namespace
  adas_core.Controllers

Assembly
  adas-core.dll

    [Route("units")]
    [ApiController]
    public class UnitController : ControllerBase

Inheritance
  object
  ControllerBase
  UnitController

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

### UnitController(ILogger<UnitController>, IUnitService, IAdminPanelService)

    public UnitController(ILogger<UnitController> logger, IUnitService unitService, IAdminPanelService adminPanelService)

#### Parameters

`logger` ILogger<UnitController>
`unitService` IUnitService
`adminPanelService` IAdminPanelService

## Methods

### Compact(string)

Retrieves a compact representation of a unit identified by the given id, requiring the caller to have display permissions on the "Source" entity. Validates that the supplied id is a well-formed identifier before delegating the lookup to the unit service.

    [HttpGet("compact/{id}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> Compact(string id)

#### Parameters

`id` string

  The string identifier of the unit to retrieve; must be a parseable identifier or a bad request is raised.

#### Returns

Task<IActionResult>

  An IActionResult containing the compact unit payload when the id is valid.

#### Exceptions

BadRequestException

  Thrown when `id` cannot be parsed as a valid identifier.

### Config(string)

GetByCodeSysAndCode unit config by unit name

    [HttpGet("{unitName}/config")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> Config(string unitName)

#### Parameters

`unitName` string

#### Returns

Task<IActionResult>

### DeleteUnit(string)

Post unit

    [HttpDelete("{id}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> DeleteUnit(string id)

#### Parameters

`id` string

#### Returns

Task<IActionResult>

### Find(string, bool)

GetByCodeSysAndCode unit by id

    [HttpGet("{id}/{listFilled}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> Find(string id, bool listFilled = true)

#### Parameters

`id` string
`listFilled` bool

#### Returns

Task<IActionResult>

### FindByPatientId(string)

    [HttpGet("{patientId}/patient-id")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> FindByPatientId(string patientId)

#### Parameters

`patientId` string

#### Returns

Task<IActionResult>

### GetPaginatedUnits(PaginationFilter, bool)

Retrieves a paginated list of units, optionally including their associated Points of Contact (PoCs), based on the supplied pagination filter.

    [HttpPost("paginated/{withPoCs}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> GetPaginatedUnits(PaginationFilter request, bool withPoCs)

#### Parameters

`request` PaginationFilter

  The pagination filter specifying the page size, page number, and any additional filtering criteria.

`withPoCs` bool

  A flag indicating whether the response should include the related PoCs for each unit.

#### Returns

Task<IActionResult>

  An IActionResult containing the paginated units wrapped in an HTTP 200 OK response.

#### Exceptions

BadRequestException

  Thrown when the `request` parameter is null, indicating missing required parameters.

### GetUnitDependency(string)

Retrieves the dependency information for the specified unit, returning it as a DTO.

    [HttpGet("{id}/dependency")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> GetUnitDependency(string id)

#### Parameters

`id` string

  The string representation of the unit's identifier used to look up the unit.

#### Returns

Task<IActionResult>

  An IActionResult containing the unit dependency DTO on success.

#### Exceptions

BadRequestException

  Thrown when `id` is not a valid format or when the dependency DTO result cannot be retrieved.

NotFoundException

  Thrown when no unit exists with the specified identifier.

### GetUnitPointOfCares(string)

Unit PointOfCares

    [HttpGet("{id}/point-of-cares")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> GetUnitPointOfCares(string id)

#### Parameters

`id` string

#### Returns

Task<IActionResult>

### List(bool)

GetByCodeSysAndCode all unit list

    [HttpGet("{withPoCs}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> List(bool withPoCs)

#### Parameters

`withPoCs` bool

#### Returns

Task<IActionResult>

  List<unit></unit>

### ListCompact()

Retrieves a compact list of units, typically used for lightweight UI scenarios such as dropdowns or lookups.

    [HttpGet("compact")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> ListCompact()

#### Returns

Task<IActionResult>

  An IActionResult containing the compact collection of units on success.

### PostUnit(Unit)

Post unit

    [HttpPost]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> PostUnit(Unit unit)

#### Parameters

`unit` Unit

#### Returns

Task<IActionResult>

### Status(string)

GetByCodeSysAndCode unit status

    [HttpGet("status/{id}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> Status(string id)

#### Parameters

`id` string

#### Returns

Task<IActionResult>

### UpdateConfiguration(string, UnitConfiguration)

Updates the configuration of a unit identified by its id, after validating the id format. Requires authentication with the AuthSome role and permission to display the "Source" resource.

    [HttpPut("{unitId}/config")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> UpdateConfiguration(string unitId, UnitConfiguration unitConfiguration)

#### Parameters

`unitId` string

  The id of the unit whose configuration will be updated, provided in the route.

`unitConfiguration` UnitConfiguration

  The new configuration values supplied in the request body.

#### Returns

Task<IActionResult>

  An IActionResult containing the updated unit configuration when the operation succeeds.

#### Exceptions

BadRequestException

  Thrown when `unitId` cannot be parsed as a valid id format.

### UpdateMasterListUnit(UpdateUnitIdListDto)

Update Unit master list Id

    [HttpPut("master-list-id")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> UpdateMasterListUnit(UpdateUnitIdListDto updateUnitListDto)

#### Parameters

`updateUnitListDto` UpdateUnitIdListDto

#### Returns

Task<IActionResult>

### UpdateSection(string, Unit)

Update Unit

    [HttpPut("{id}")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> UpdateSection(string id, Unit unit)

#### Parameters

`id` string
`unit` Unit

#### Returns

Task<IActionResult>

### UpdateUnitInfo(UnitInfoDto, string)

Update Unit

    [HttpPut("{id}/info")]
    [AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
    [PermissionAuthorize("Source", "DisplayId")]
    public Task<IActionResult> UpdateUnitInfo(UnitInfoDto request, string id)

#### Parameters

`request` UnitInfoDto
`id` string

#### Returns

Task<IActionResult>