# 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
  object
  CameraService

Implements
  ICameraService

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## 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

`logger` ILogger<CameraService>
`cameraRepository` ICameraRepository
`pointOfCareService` IPointOfCareService

#### 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

`objectId` ObjectId

  The unique identifier of the camera to delete.

#### Returns

Task<bool>

  `true` if the camera was successfully deleted; otherwise, `false`.

### 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

`relayId` ObjectId

  The 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

`configurationRelayList` List<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

`filter` PaginationFilter

  The 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

`textToSearch` string

  The 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

`camera` Camera

  The camera entity to insert.

#### Returns

Task<Camera>

  The inserted camera, or null if the insertion did not return a result.

#### 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

`objectId` ObjectId

  The unique identifier of the camera to update.

`camera` Camera

  The camera data containing the updated values.

#### Returns

Task<Camera>

  A task that represents the asynchronous operation. The task result contains the updated Camera, or `null` if no camera with the specified identifier was found.