Class ConfigPumpsRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Repository for managing ConfigPumps in MongoDB. Provides methods to retrieve, update, and delete pump configurations.
public class ConfigPumpsRepository : MongoRepository<ConfigPumps>, IConfigPumpsRepository, IMongoRepository<ConfigPumps>
- Inheritance
-
ConfigPumpsRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
ConfigPumpsRepository(IOptions<ApiSettings>, IMongoDatabase)
Initializes a new instance of the ConfigPumpsRepository class with the specified API settings and MongoDB database.
public ConfigPumpsRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>The API settings.
databaseIMongoDatabaseThe MongoDB database instance.
Exceptions
- ArgumentNullException
Thrown when apiSettings is null.
Methods
DeleteConfig(ConfigPumps)
Deletes a ConfigPumps document from the MongoDB collection based on its Id. The method takes a ConfigPumps object, deletes the corresponding document, and returns true if the deletion was successful (i.e., the document no longer exists), or false if the document still exists after the deletion attempt.
public Task<bool> DeleteConfig(ConfigPumps config)
Parameters
configConfigPumpsThe ConfigPumps object to be deleted.
Returns
FindById(string)
Finds a ConfigPumps document by its unique identifier. Returns the ConfigPumps if found, or null if not found.
public Task<ConfigPumps?> FindById(string id)
Parameters
idstringThe unique identifier of the ConfigPumps document.
Returns
- Task<ConfigPumps>
The ConfigPumps document if found, or null if not found.
GetAllConfigs()
Retrieves all ConfigPumps documents from the MongoDB collection. Returns a list of ConfigPumps or null if no documents are found.
public Task<List<ConfigPumps>?> GetAllConfigs()
Returns
- Task<List<ConfigPumps>>
A list of ConfigPumps or null if no documents are found.
GetCollectionName()
Gets the name of the MongoDB collection for ConfigPumps. Uses the value from API settings or defaults to "config_pumps".
public override string GetCollectionName()
Returns
- string
The name of the MongoDB collection for ConfigPumps.
UpdateConfig(ConfigPumps)
Updates an existing ConfigPumps document in the MongoDB collection. The method takes a ConfigPumps object, updates the corresponding document based on its Id, and returns the updated ConfigPumps. If the document is not found, it returns null.
public Task<ConfigPumps?> UpdateConfig(ConfigPumps config)
Parameters
configConfigPumpsThe ConfigPumps object containing the updated data.
Returns
- Task<ConfigPumps>
The updated ConfigPumps document if found, or null if not found.