# Class PumpAlarmEventRepository

Namespace
  adas_core.Infrastructure.Repositories

Assembly
  adas-core.Infrastructure.dll

Represents a MongoDB-backed repository for PumpAlarmEvent documents, exposing pump alarm event-specific data access through the IPumpAlarmEventRepository contract.

    public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IMongoRepository<PumpAlarmEvent>, IPumpAlarmEventRepository

Inheritance
  object
  MongoRepository<PumpAlarmEvent>
  PumpAlarmEventRepository

Implements
  IMongoRepository<PumpAlarmEvent>
  IPumpAlarmEventRepository

Inherited Members
  MongoRepository<PumpAlarmEvent>.Db
  MongoRepository<PumpAlarmEvent>.Collection
  MongoRepository<PumpAlarmEvent>.InsertOneAsync(PumpAlarmEvent)
  MongoRepository<PumpAlarmEvent>.UpdateOneAsync(ObjectId, PumpAlarmEvent)
  MongoRepository<PumpAlarmEvent>.DeleteAsync(ObjectId)
  MongoRepository<PumpAlarmEvent>.InsertInitialLoad()
  MongoRepository<PumpAlarmEvent>.InsertManyAsync(List<PumpAlarmEvent>)
  MongoRepository<PumpAlarmEvent>.UpdateManyObjectIdAsync(string, ObjectId, ObjectId)
  MongoRepository<PumpAlarmEvent>.DeleteAsync(string)
  MongoRepository<PumpAlarmEvent>.CollectionExists(string)
  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

Inherits the generic MongoDB persistence capabilities of MongoRepository<T>, specializing them for the PumpAlarmEvent entity type.

## Constructors

### PumpAlarmEventRepository(IOptions<ApiSettings>, IMongoDatabase)

    public PumpAlarmEventRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)

#### Parameters

`apiSettings` IOptions<ApiSettings>
`database` IMongoDatabase

## Methods

### CreateIndexes()

Creates the indexes required for the collection. The base implementation is a no-op; derived classes should override this method to define their own indexes.

    public override Task CreateIndexes()

#### Returns

Task

  A Task representing the asynchronous index creation operation.

### DeleteByPatientId(ObjectId)

Deletes records associated with the specified patient identifier.

    public Task DeleteByPatientId(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose records should be deleted.

#### Returns

Task

### FindByDeviceIdAsync(string, DateTime?, DateTime?, int?)

Retrieves pump alarm events associated with the specified device, optionally filtered by a date range and capped by a maximum result count.

    public Task<IEnumerable<PumpAlarmEvent>> FindByDeviceIdAsync(string deviceId, DateTime? from = null, DateTime? to = null, int? limit = null)

#### Parameters

`deviceId` string

  The unique identifier of the device whose alarm events should be returned.

`from` DateTime?

  Optional start of the date range used to filter the events.

`to` DateTime?

  Optional end of the date range used to filter the events.

`limit` int?

  Optional maximum number of alarm events to return.

#### Returns

Task<IEnumerable<PumpAlarmEvent>>

  A task that represents the asynchronous operation, containing the collection of pump alarm events matching the criteria.

### FindLastByDeviceIdAsync(string)

Asynchronously retrieves the most recent pump alarm event associated with the specified device identifier. Returns null if no alarm event is found for the given device.

    public Task<PumpAlarmEvent?> FindLastByDeviceIdAsync(string deviceId)

#### Parameters

`deviceId` string

  The unique identifier of the device whose last pump alarm event is to be retrieved.

#### Returns

Task<PumpAlarmEvent>

  A task that represents the asynchronous operation, containing the most recent PumpAlarmEvent for the device, or null if none exists.

### GetCollectionName()

When implemented in a derived class, returns the name of the MongoDB collection used to store documents of type PumpAlarmEvent.

    public override string GetCollectionName()

#### Returns

string

  The MongoDB collection name as a string.

### InsertAsync(PumpAlarmEvent)

Asynchronously inserts a pump alarm event into the underlying data store.

    public Task InsertAsync(PumpAlarmEvent alarmEvent)

#### Parameters

`alarmEvent` PumpAlarmEvent

  The pump alarm event to be persisted.

#### Returns

Task

### UpdateManyObjectIdByFiledNameAsync(string, ObjectId, ObjectId)

Asynchronously updates the ObjectId value of multiple records where the specified field currently matches the old identifier, replacing it with the new identifier.

    public Task<long> UpdateManyObjectIdByFiledNameAsync(string fieldName, ObjectId newId, ObjectId oldId)

#### Parameters

`fieldName` string

  The name of the field whose value should be updated.

`newId` ObjectId

  The new ObjectId value to assign to the matching records.

`oldId` ObjectId

  The existing ObjectId value used to identify the records to be updated.

#### Returns

Task<long>

  A task that represents the asynchronous operation, containing the number of records that were updated.