# Interface IDeviceRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface IDeviceRepository : IMongoRepository<Device>

Inherited Members
  IMongoRepository<Device>.Collection
  IMongoRepository<Device>.GetCollectionName()
  IMongoRepository<Device>.InsertOneAsync(Device)
  IMongoRepository<Device>.DeleteAsync(ObjectId)
  IMongoRepository<Device>.UpdateOneAsync(ObjectId, Device)

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

## Methods

### FindByKey(string)

Retrieves a device by its unique key identifier.

    Task<Device?> FindByKey(string deviceDtoKey)

#### Parameters

`deviceDtoKey` string

  The key identifier of the device to look up.

#### Returns

Task<Device>

  A task that represents the asynchronous operation. The task result contains the Device if a matching device is found, or `null` if no device corresponds to the specified key.

### FindByMacAddr(string)

Asynchronously retrieves a device matching the specified MAC address, returning null if no matching device is found.

    Task<Device?> FindByMacAddr(string deviceDtoMacAddr)

#### Parameters

`deviceDtoMacAddr` string

  The MAC address used to look up the device.

#### Returns

Task<Device>

  A task that represents the asynchronous operation, containing the matching Device or null when no device is found.

### FindBySerialNumber(string)

Finds and returns the device matching the specified serial number, or `null` if no matching device is found.

    Task<Device?> FindBySerialNumber(string deviceDtoSerialNumber)

#### Parameters

`deviceDtoSerialNumber` string

  The serial number used to look up the device.

#### Returns

Task<Device>

  A Device instance if a match is found; otherwise, `null`.

### FindByUuid(string)

Asynchronously finds a device by its unique identifier (UUID) and returns the matching device, or null if no device is found.

    Task<Device?> FindByUuid(string deviceDtoUuid)

#### Parameters

`deviceDtoUuid` string

  The UUID string used to look up the device.

#### Returns

Task<Device>

  A Task<TResult> that resolves to the matching Device, or null when no device matches the provided UUID.

### UpdateDeviceStats(ObjectId, DeviceDto)

Updates the statistics of an existing device identified by the specified identifier.

    Task UpdateDeviceStats(ObjectId id, DeviceDto deviceExist)

#### Parameters

`id` ObjectId

  The unique identifier of the device whose statistics will be updated.

`deviceExist` DeviceDto

  The device data transfer object representing the existing device to be updated.

#### Returns

Task

  A task that represents the asynchronous update operation.