Interface IUnitService
- Namespace
- adas_core.Application.Services.Interfaces
- Assembly
- adas-core.Application.dll
public interface IUnitService
- Extension Methods
Methods
CountUnitsByMasterListId(ObjectId, MasterListType)
Asynchronously counts the number of units associated with the specified master list, filtered by the given master list type.
Task<long> CountUnitsByMasterListId(ObjectId masterListId, MasterListType masterListType)
Parameters
masterListIdObjectIdThe unique identifier of the master list whose units should be counted.
masterListTypeMasterListTypeThe type of the master list used to scope the count to the appropriate unit category.
Returns
- Task<long>
A Task<TResult> that represents the asynchronous operation, containing the total number of units matching the specified master list.
DeleteUnitById(Unit)
Asynchronously deletes a unit identified by the provided unit entity's identifier.
Task<bool> DeleteUnitById(Unit unit)
Parameters
unitUnitThe unit entity whose identifier is used to locate and delete the record.
Returns
- Task<bool>
A Task<TResult> that represents the asynchronous operation, containing a value indicating whether the unit was successfully deleted.
FindById(ObjectId?)
Asynchronously finds and returns a Unit matching the specified identifier.
Task<Unit?> FindById(ObjectId? id)
Parameters
idObjectId?The unique identifier of the Unit to retrieve. May be
null.
Returns
- Task<Unit>
A task that represents the asynchronous operation. The task result contains the Unit if found; otherwise,
null.
FindByName(string?)
Asynchronously retrieves a Unit entity matching the specified name.
Task<Unit?> FindByName(string? name)
Parameters
namestringThe name used to look up the unit. Can be null.
Returns
FindByPatientId(ObjectId)
Asynchronously retrieves the unit associated with the specified patient identifier, returning null when no matching unit exists.
Task<Unit?> FindByPatientId(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose unit is being looked up.
Returns
- Task<Unit>
A task that represents the asynchronous lookup, containing the matching Unit if found, or
nullif no unit is associated with the patient.
FindByUnitNameOrPocName(string?, string?)
Asynchronously retrieves a Unit by matching either its unit name or point-of-contact (POC) name.
Returns null if no matching unit is found.
Task<Unit?> FindByUnitNameOrPocName(string? name, string? pocName)
Parameters
namestringThe unit name to search for. May be
null.pocNamestringThe point-of-contact (POC) name to search for. May be
null.
Returns
- Task<Unit>
A Task<TResult> containing the matched Unit, or
nullif no unit is found.
FindUnitsByMasterListId(ObjectId)
Asynchronously retrieves the collection of units associated with the specified master list identifier.
Task<IEnumerable<Unit>> FindUnitsByMasterListId(ObjectId masterListId)
Parameters
masterListIdObjectIdThe identifier of the master list whose units are to be retrieved.
Returns
- Task<IEnumerable<Unit>>
A task that represents the asynchronous operation, containing the collection of units that belong to the specified master list.
FindUnitsByMasterListId(ObjectId, MasterListType)
Asynchronously retrieves the collection of units associated with the specified master list identifier and master list type. Returns null when no matching units are found.
Task<IEnumerable<Unit>?> FindUnitsByMasterListId(ObjectId masterListId, MasterListType masterListType)
Parameters
masterListIdObjectIdThe unique identifier of the master list whose units should be retrieved.
masterListTypeMasterListTypeThe type of the master list used to scope the unit lookup.
Returns
- Task<IEnumerable<Unit>>
A task that returns an IEnumerable<T> of Unit when matches exist, or null when no matching units are found.
GetAll(bool)
Asynchronously retrieves all units, with an option to include their associated POCs.
Task<List<Unit>> GetAll(bool withPocs = false)
Parameters
withPocsboolIndicates whether the returned units should include their associated POCs.
Returns
GetAllCompact()
Asynchronously retrieves a compact list of all units, returning minimal summary information for each unit.
Task<List<UnitInfoDto>> GetAllCompact()
Returns
- Task<List<UnitInfoDto>>
A task that represents the asynchronous operation. The task result contains a list of UnitInfoDto objects with the compact information of all units.
GetByName(string)
Asynchronously retrieves a Unit by its name.
Task<Unit?> GetByName(string unit)
Parameters
unitstringThe name of the unit to look up.
Returns
- Task<Unit>
A task that represents the asynchronous operation. The task result contains the matching Unit if found; otherwise,
null.
GetInfo(ObjectId, bool, bool)
Retrieves information about a unit identified by the specified id, optionally including related points of contact and devices.
Task<Unit?> GetInfo(ObjectId id, bool withPoCs = true, bool withDevices = true)
Parameters
idObjectIdThe identifier of the unit to retrieve information for.
withPoCsboolIndicates whether related points of contact should be included in the result. Defaults to
true.withDevicesboolIndicates whether related devices should be included in the result. Defaults to
true.
Returns
- Task<Unit>
A task that represents the asynchronous operation. The task result contains the
Unitif found, ornullif no unit matches the specified identifier.
GetInfo(ObjectId, LocaleEnum?, bool, bool)
Retrieves information for a unit identified by the specified id, returning null when no matching unit is found.
Task<Unit?> GetInfo(ObjectId id, LocaleEnum? dataLocale, bool fillLists = true, bool withPoCs = false)
Parameters
idObjectIdThe unique identifier of the unit to look up.
dataLocaleLocaleEnum?Optional locale used to localize the returned unit data.
fillListsboolWhen true, populates the related lists on the returned unit.
withPoCsboolWhen true, includes the unit's points of contact in the result.
Returns
GetOneCompact(ObjectId)
Retrieves a compact representation of a unit info by its identifier.
Task<UnitInfoDto> GetOneCompact(ObjectId id)
Parameters
idObjectIdThe unique identifier of the unit to retrieve.
Returns
- Task<UnitInfoDto>
A task that represents the asynchronous operation, containing the compact unit information.
GetPaginatedUnits(PaginationFilter, bool)
Retrieves a paginated list of units based on the provided filter, optionally including their associated points of contact.
Task<PaginationResponse<Unit>> GetPaginatedUnits(PaginationFilter filter, bool withPoCs)
Parameters
filterPaginationFilterThe pagination filter that defines the page size, page number, and any additional query criteria.
withPoCsboolA flag indicating whether the response should include the points of contact associated with each unit.
Returns
- Task<PaginationResponse<Unit>>
A task that represents the asynchronous operation, containing the paginated response of units.
InsertOne(Unit)
Inserts a single Unit into the underlying data store and returns the resulting entity wrapped in a task.
Task<Unit?> InsertOne(Unit unit)
Parameters
Returns
- Task<Unit>
A task that resolves to the inserted Unit, or
nullif the insertion did not produce a result.
UpdateConfiguration(ObjectId, UnitConfiguration)
Asynchronously updates the configuration for the specified unit using the provided configuration data.
Task<bool> UpdateConfiguration(ObjectId unitIdParsed, UnitConfiguration unitConfiguration)
Parameters
unitIdParsedObjectIdThe parsed identifier of the unit whose configuration will be updated.
unitConfigurationUnitConfigurationThe new configuration values to apply to the unit.
Returns
- Task<bool>
A task that resolves to
trueif the configuration was successfully updated; otherwise,false.
UpdateUnit(Unit)
Updates the specified unit in the system.
Task<Unit?> UpdateUnit(Unit unit)
Parameters
unitUnitThe unit containing the updated information to persist.
Returns
UpdateUnitInfo(ObjectId, string, string, string?)
Updates the information of an existing unit identified by unitId, including its name, title, and optionally its configuration object ID.
Returns the updated unit, or null when no matching unit is found.
Task<Unit?> UpdateUnitInfo(ObjectId unitId, string name, string title, string? configObsId = null)
Parameters
unitIdObjectIdThe identifier of the unit to update.
namestringThe new name to assign to the unit.
titlestringThe new title to assign to the unit.
configObsIdstringAn optional configuration object ID to associate with the unit.
Returns
UpdateUnitMasterList(UpdateUnitIdListDto)
Updates the unit master list based on the provided unit ID list DTO.
Task<Unit?> UpdateUnitMasterList(UpdateUnitIdListDto updateUnitListDto)
Parameters
updateUnitListDtoUpdateUnitIdListDtoThe DTO containing the list of unit IDs to be used for updating the master list.