Class CameraService
- Namespace
- adas_core.Application.Services
- Assembly
- adas-core.Application.dll
Provides camera-related operations by coordinating the camera repository and point-of-care service, and logging diagnostic information.
public class CameraService : ICameraService
- Inheritance
-
CameraService
- Implements
- Inherited Members
- Extension Methods
Remarks
This service implements ICameraService and serves as the application-layer entry point for camera functionality.
Constructors
CameraService(ILogger<CameraService>, ICameraRepository, IPointOfCareService)
Provides camera-related operations by coordinating the camera repository and point-of-care service, and logging diagnostic information.
public CameraService(ILogger<CameraService> logger, ICameraRepository cameraRepository, IPointOfCareService pointOfCareService)
Parameters
loggerILogger<CameraService>cameraRepositoryICameraRepositorypointOfCareServiceIPointOfCareService
Remarks
This service implements ICameraService and serves as the application-layer entry point for camera functionality.
Methods
DeleteCamera(ObjectId)
Deletes a camera identified by the specified object identifier. Returns false when the camera is not found, and logs and returns false if an error occurs during the operation.
public Task<bool> DeleteCamera(ObjectId objectId)
Parameters
objectIdObjectIdThe unique identifier of the camera to delete.
Returns
GetById(ObjectId)
Retrieves a camera by its associated relay identifier from the camera repository. Returns null when no camera is found for the specified relay identifier.
public Task<Camera?> GetById(ObjectId relayId)
Parameters
relayIdObjectIdThe unique identifier of the relay used to look up the camera.
Returns
- Task<Camera>
A task that represents the asynchronous operation. The task result contains the matching Camera, or null if no camera is found.
GetCameraInList(List<ObjectId>)
Retrieves the list of cameras associated with the specified configuration relay identifiers.
public List<Camera> GetCameraInList(List<ObjectId> configurationRelayList)
Parameters
configurationRelayListList<ObjectId>The list of configuration relay identifiers used to look up the corresponding cameras.
Returns
- List<Camera>
A List<T> containing the cameras linked to the provided configuration relay identifiers.
GetPaginatedCameras(PaginationFilter)
Retrieves a paginated list of cameras, optionally filtered by whether they are currently in use, and resolves the in-use status for each returned camera using the point-of-care service.
public Task<PaginationResponse<Camera>> GetPaginatedCameras(PaginationFilter filter)
Parameters
filterPaginationFilterThe pagination filter that controls page number, page size, and optional filtering criteria such as the in-use flag.
Returns
- Task<PaginationResponse<Camera>>
A paginated response containing the requested cameras, the current page metadata, and the total document count; if no data is found, an empty paginated response is returned.
GetSearchByNameCameras(string)
Retrieves a list of cameras matching the specified search text by delegating to the camera repository.
public Task<List<Camera>> GetSearchByNameCameras(string textToSearch)
Parameters
textToSearchstringThe search text used to find cameras by name.
Returns
- Task<List<Camera>>
A task that represents the asynchronous operation, containing a list of Camera objects that match the search criteria.
InsertCamera(Camera)
Inserts a new camera into the system after validating its name and ensuring no duplicate exists. Throws an exception if the camera name is null or if another camera with the same name already exists.
public Task<Camera?> InsertCamera(Camera camera)
Parameters
cameraCameraThe camera entity to insert.
Returns
Exceptions
- Exception
Thrown when the camera name is null.
- Exception
Thrown when a camera with the same name already exists.
UpdateCameraById(ObjectId, Camera)
Updates an existing camera identified by its unique identifier, returning the updated entity if the operation succeeds.
public Task<Camera?> UpdateCameraById(ObjectId objectId, Camera camera)
Parameters
objectIdObjectIdThe unique identifier of the camera to update.
cameraCameraThe camera data containing the updated values.