Class PumpAlarmStateRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Represents a MongoDB-based repository for PumpAlarmState entities, providing concrete data access functionality defined by the IPumpAlarmStateRepository contract.
public class PumpAlarmStateRepository : MongoRepository<PumpAlarmState>, IMongoRepository<PumpAlarmState>, IPumpAlarmStateRepository
- Inheritance
-
PumpAlarmStateRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
PumpAlarmStateRepository(IOptions<ApiSettings>, IMongoDatabase)
public PumpAlarmStateRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>databaseIMongoDatabase
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
DeleteByPatientId(ObjectId)
Asynchronously deletes all records associated with the specified patient identifier by removing every document whose PatientId matches the supplied value.
public Task DeleteByPatientId(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose associated records should be removed.
Returns
FindActiveAsync(string, AlarmType?, string?)
Retrieves the first active PumpAlarmState matching the specified device and optional alarm criteria.
The filter is always constrained by deviceId, and additionally by alarmType and alarmCodeMdc when those values are provided.
Returns null when no matching alarm state is found.
public Task<PumpAlarmState?> FindActiveAsync(string deviceId, PumpEnum.AlarmType? alarmType, string? alarmCodeMdc = null)
Parameters
deviceIdstringThe identifier of the device whose alarm state should be retrieved. Always applied to the query filter.
alarmTypePumpEnum.AlarmType?The optional alarm type used to further narrow the filter. When
null, the alarm type is not applied.alarmCodeMdcstringThe optional alarm code (MDC) used to further narrow the filter. Ignored when
null, empty, or whitespace.
Returns
- Task<PumpAlarmState>
A PumpAlarmState instance if a matching record is found; otherwise,
null.
FindAllActiveByDeviceAsync(string)
Asynchronously retrieves all pump alarm states associated with the specified device identifier.
public Task<IEnumerable<PumpAlarmState>> FindAllActiveByDeviceAsync(string deviceId)
Parameters
deviceIdstringThe unique identifier of the device whose pump alarm states are being queried.
Returns
- Task<IEnumerable<PumpAlarmState>>
A task that represents the asynchronous operation. The task result contains an IEnumerable<T> with the pump alarm states matching the provided device identifier.
GetCollectionName()
Gets the collection name for the pump alarm state, returning the value configured in the API settings or the default "pump_alarm_state" when the configuration is not set.
public override string GetCollectionName()
Returns
- string
The configured collection name, or the default "pump_alarm_state" if the API setting is null.
RemoveAsync(string?, AlarmType?, string?)
Removes pump alarm state records from the collection that match the specified device identifier, optionally narrowed by alarm type and/or alarm code MDC.
public Task RemoveAsync(string? deviceId, PumpEnum.AlarmType? alarmType, string? alarmCodeMdc = null)
Parameters
deviceIdstringThe identifier of the device whose alarm state records should be removed. Used as a mandatory filter criterion.
alarmTypePumpEnum.AlarmType?The optional alarm type to further restrict which records are deleted. When null, records of any alarm type for the device are removed.
alarmCodeMdcstringThe optional alarm code MDC used to further narrow the deletion. Blank or whitespace values are ignored.
Returns
UpdateManyObjectIdByFieldNameAsync(string, ObjectId, ObjectId)
Asynchronously updates all PumpAlarmState documents that match the specified oldId on the given fieldName, replacing the value with newId. Used to bulk rewire MongoDB.Bson.ObjectId references stored on a dynamic field.
public Task<long> UpdateManyObjectIdByFieldNameAsync(string fieldName, ObjectId newId, ObjectId oldId)
Parameters
fieldNamestringName of the document field to filter and update.
newIdObjectIdThe new MongoDB.Bson.ObjectId value to assign to the field.
oldIdObjectIdThe existing MongoDB.Bson.ObjectId value used to locate matching documents.
Returns
UpsertActiveAsync(PumpAlarmState)
Inserts a new active pump alarm state or updates the existing one, maintaining the current state for the alarm.
public Task UpsertActiveAsync(PumpAlarmState state)
Parameters
statePumpAlarmStateThe pump alarm state to upsert as the active record.