Table of Contents

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

masterListId ObjectId

The unique identifier of the master list whose units should be counted.

masterListType MasterListType

The 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

unit Unit

The 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

id ObjectId?

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

name string

The name used to look up the unit. Can be null.

Returns

Task<Unit>

A task that resolves to the matching Unit if found; otherwise, null.

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

patientId ObjectId

The 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 null if 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

name string

The unit name to search for. May be null.

pocName string

The point-of-contact (POC) name to search for. May be null.

Returns

Task<Unit>

A Task<TResult> containing the matched Unit, or null if 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

masterListId ObjectId

The 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

masterListId ObjectId

The unique identifier of the master list whose units should be retrieved.

masterListType MasterListType

The 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

withPocs bool

Indicates whether the returned units should include their associated POCs.

Returns

Task<List<Unit>>

A task representing the asynchronous operation, containing the list of units.

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

unit string

The 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

id ObjectId

The identifier of the unit to retrieve information for.

withPoCs bool

Indicates whether related points of contact should be included in the result. Defaults to true.

withDevices bool

Indicates 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 Unit if found, or null if 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

id ObjectId

The unique identifier of the unit to look up.

dataLocale LocaleEnum?

Optional locale used to localize the returned unit data.

fillLists bool

When true, populates the related lists on the returned unit.

withPoCs bool

When true, includes the unit's points of contact in the result.

Returns

Task<Unit>

A task that yields the located Unit, or null if no unit matches the given id.

GetOneCompact(ObjectId)

Retrieves a compact representation of a unit info by its identifier.

Task<UnitInfoDto> GetOneCompact(ObjectId id)

Parameters

id ObjectId

The 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

filter PaginationFilter

The pagination filter that defines the page size, page number, and any additional query criteria.

withPoCs bool

A 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

unit Unit

The Unit instance to be inserted.

Returns

Task<Unit>

A task that resolves to the inserted Unit, or null if 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

unitIdParsed ObjectId

The parsed identifier of the unit whose configuration will be updated.

unitConfiguration UnitConfiguration

The new configuration values to apply to the unit.

Returns

Task<bool>

A task that resolves to true if the configuration was successfully updated; otherwise, false.

UpdateUnit(Unit)

Updates the specified unit in the system.

Task<Unit?> UpdateUnit(Unit unit)

Parameters

unit Unit

The unit containing the updated information to persist.

Returns

Task<Unit>

A task that returns the updated Unit, or null if the unit was not found.

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

unitId ObjectId

The identifier of the unit to update.

name string

The new name to assign to the unit.

title string

The new title to assign to the unit.

configObsId string

An optional configuration object ID to associate with the unit.

Returns

Task<Unit>

A task that yields the updated Unit, or null if the unit does not exist.

UpdateUnitMasterList(UpdateUnitIdListDto)

Updates the unit master list based on the provided unit ID list DTO.

Task<Unit?> UpdateUnitMasterList(UpdateUnitIdListDto updateUnitListDto)

Parameters

updateUnitListDto UpdateUnitIdListDto

The DTO containing the list of unit IDs to be used for updating the master list.

Returns

Task<Unit>

A task that represents the asynchronous operation. The task result contains the updated Unit, or null if the update was not applicable.