Class DeviceService
- Namespace
- adas_core.Application.Services
- Assembly
- adas-core.Application.dll
Provides the concrete implementation of the IDeviceService contract, handling device-related service operations defined by the interface.
public class DeviceService : IDeviceService
- Inheritance
-
DeviceService
- Implements
- Inherited Members
- Extension Methods
Constructors
DeviceService(IDeviceRepository, IPointOfCareService, ILogger<DeviceService>, IObservationService, IConfigObservationService, IAlarmService)
public DeviceService(IDeviceRepository deviceRepository, IPointOfCareService pointOfCareService, ILogger<DeviceService> logger, IObservationService observationService, IConfigObservationService configObservationService, IAlarmService alarmService)
Parameters
deviceRepositoryIDeviceRepositorypointOfCareServiceIPointOfCareServiceloggerILogger<DeviceService>observationServiceIObservationServiceconfigObservationServiceIConfigObservationServicealarmServiceIAlarmService
Methods
Create(DeviceDto)
Creates a new device entity from the provided DTO, sets the creation and update timestamps to the current UTC time, and persists it via the device repository.
public Task<Device?> Create(DeviceDto deviceDto)
Parameters
deviceDtoDeviceDtoThe data transfer object containing the device information to be mapped and stored.
Returns
- Task<Device>
The created Device entity after successful insertion, or null if the device could not be created.
Delete(ObjectId)
Deletes an object identified by the specified objectId by delegating to the device repository.
Returns true when the repository's delete operation yields a non-null result, and false when the result is null (e.g., the object was not found or could not be deleted).
public Task<bool> Delete(ObjectId objectId)
Parameters
objectIdObjectIdThe unique identifier of the object to delete.
Returns
ReceiveEvent(DeviceDto)
Processes an incoming device event by locating an existing device or creating a new one, then handling device-type-specific logic. Looks up the device using the MAC address, serial number, UUID, or key in that order, falling back to creating a new record when no match is found. When the device is a button, additional button management logic is invoked.
public Task<Device?> ReceiveEvent(DeviceDto deviceDto)
Parameters
deviceDtoDeviceDtoThe data transfer object containing the device information from the event, used for lookup and creation.
Returns
ToEntity(DeviceDto)
Converts a DeviceDto into a Device entity by mapping its properties. Applies a fallback to an empty list when PointOfCareIds is null, and to a new DeviceSettings instance when Settings is null.
public Device ToEntity(DeviceDto dto)
Parameters
dtoDeviceDtoThe data transfer object containing the device information to convert.
Returns
Update(DeviceDto)
Updates an existing device by mapping the provided DTO to a device entity, setting the update timestamp, and persisting the changes through the repository.
public Task<Device?> Update(DeviceDto deviceDto)
Parameters
deviceDtoDeviceDtoThe data transfer object containing the updated device information.