Table of Contents

Class PumpStateRepository

Namespace
adas_core.Infrastructure.Repositories
Assembly
adas-core.Infrastructure.dll

Provides a repository implementation for PumpState entities backed by a MongoDB data store.

public class PumpStateRepository : MongoRepository<PumpState>, IMongoRepository<PumpState>, IPumpStateRepository
Inheritance
PumpStateRepository
Implements
Inherited Members
Extension Methods

Remarks

Inherits base functionality from MongoRepository<T> and implements the IPumpStateRepository contract.

Constructors

PumpStateRepository(IOptions<ApiSettings>, IMongoDatabase)

public PumpStateRepository(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.

FindByDeviceIdAsync(string)

Retrieves the pump state associated with the specified device identifier, returning null when no matching record exists.

public Task<PumpState?> FindByDeviceIdAsync(string deviceId)

Parameters

deviceId string

The unique identifier of the device whose pump state should be looked up.

Returns

Task<PumpState>

A PumpState instance if a matching record is found; otherwise, null.

GetAllAsync()

Asynchronously retrieves all PumpState records from the data store.

public Task<IEnumerable<PumpState>> GetAllAsync()

Returns

Task<IEnumerable<PumpState>>

A task that represents the asynchronous operation, containing an IEnumerable<T> of all PumpState records; an empty collection is returned if no records exist.

GetCollectionName()

Retrieves the collection name for pump states, returning the configured value from API settings or the default name "pump_states" when the setting is not provided.

public override string GetCollectionName()

Returns

string

The configured pump states collection name, or the default value "pump_states" if the setting is null.

UpsertAsync(PumpState)

Inserts the specified PumpState or updates the existing one identified by its DeviceId. If a matching record is found, its identifier is reused; otherwise a new identifier is generated when the provided one is empty.

public Task UpsertAsync(PumpState state)

Parameters

state PumpState

The pump state to persist. Its Id is preserved or assigned based on whether a record with the same DeviceId already exists.

Returns

Task