Class UnitController
- Namespace
- adas_core.Controllers
- Assembly
- adas-core.dll
[Route("units")]
[ApiController]
public class UnitController : ControllerBase
- Inheritance
-
UnitController
- Inherited Members
- Extension Methods
Constructors
UnitController(ILogger<UnitController>, IUnitService, IAdminPanelService)
public UnitController(ILogger<UnitController> logger, IUnitService unitService, IAdminPanelService adminPanelService)
Parameters
loggerILogger<UnitController>unitServiceIUnitServiceadminPanelServiceIAdminPanelService
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
idstringThe 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
idcannot 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
unitNamestring
Returns
DeleteUnit(string)
Post unit
[HttpDelete("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteUnit(string id)
Parameters
idstring
Returns
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
Returns
FindByPatientId(string)
[HttpGet("{patientId}/patient-id")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> FindByPatientId(string patientId)
Parameters
patientIdstring
Returns
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
requestPaginationFilterThe pagination filter specifying the page size, page number, and any additional filtering criteria.
withPoCsboolA 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
requestparameter 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
idstringThe 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
idis 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
idstring
Returns
List(bool)
GetByCodeSysAndCode all unit list
[HttpGet("{withPoCs}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> List(bool withPoCs)
Parameters
withPoCsbool
Returns
- Task<IActionResult>
List
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
unitUnit
Returns
Status(string)
GetByCodeSysAndCode unit status
[HttpGet("status/{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> Status(string id)
Parameters
idstring
Returns
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
unitIdstringThe id of the unit whose configuration will be updated, provided in the route.
unitConfigurationUnitConfigurationThe 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
unitIdcannot 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
updateUnitListDtoUpdateUnitIdListDto
Returns
UpdateSection(string, Unit)
Update Unit
[HttpPut("{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateSection(string id, Unit unit)
Parameters
Returns
UpdateUnitInfo(UnitInfoDto, string)
Update Unit
[HttpPut("{id}/info")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateUnitInfo(UnitInfoDto request, string id)
Parameters
requestUnitInfoDtoidstring