Class ConfigPumpsService
- Namespace
- adas_core.Application.Services
- Assembly
- adas-core.Application.dll
public class ConfigPumpsService : IConfigPumpsService
- Inheritance
-
ConfigPumpsService
- Implements
- Inherited Members
- Extension Methods
Constructors
ConfigPumpsService(IConfigPumpsRepository, IOptions<ApiSettings>, ILogger<ConfigPumpsService>, IHttpContextAccessor, ILocalAuditService)
public ConfigPumpsService(IConfigPumpsRepository configPumpsRepository, IOptions<ApiSettings> apiSettings, ILogger<ConfigPumpsService> logger, IHttpContextAccessor httpContextAccessor, ILocalAuditService auditService)
Parameters
configPumpsRepositoryIConfigPumpsRepositoryapiSettingsIOptions<ApiSettings>loggerILogger<ConfigPumpsService>httpContextAccessorIHttpContextAccessorauditServiceILocalAuditService
Methods
DeletePumpConfig(ConfigPumps)
Deletes a pump configuration asynchronously, auditing the change on success and returning false if the repository operation reports an error or an exception is thrown.
public Task<bool> DeletePumpConfig(ConfigPumps config)
Parameters
configConfigPumpsThe ConfigPumps instance representing the pump configuration to delete.
Returns
- Task<bool>
A task that resolves to
truewhen the configuration is deleted and the audit log is recorded;falsewhen the delete operation fails or an exception occurs.
Get()
Asynchronously retrieves the list of configuration pump items by fetching the current configuration. Returns a null list if the underlying configuration is not available.
public Task<List<ConfigPumpItem>?> Get()
Returns
- Task<List<ConfigPumpItem>>
A task containing a list of ConfigPumpItem objects, or
nullif the configuration could not be retrieved.
GetAllPumpConfigs()
Retrieves all available pump configurations from the underlying repository.
public Task<List<ConfigPumps>?> GetAllPumpConfigs()
Returns
- Task<List<ConfigPumps>>
A task that represents the asynchronous operation, containing a list of ConfigPumps if any are available, or
nullwhen no configurations exist.
GetConfigItems(string)
Retrieves the list of configuration items associated with the config pump identified by the given identifier. Returns null when no matching config pump is found in the repository.
public Task<List<ConfigPumpItem>?> GetConfigItems(string id)
Parameters
idstringThe unique identifier of the config pump to look up.
Returns
- Task<List<ConfigPumpItem>>
A task that resolves to the list of ConfigPumpItem entries, or
nullif the config pump does not exist.
GetPumpConfigById(string)
Retrieves the configuration for a pump identified by its unique identifier from the configuration repository.
Returns null when no matching pump configuration is found.
public Task<ConfigPumps?> GetPumpConfigById(string id)
Parameters
idstringThe unique identifier of the pump configuration to retrieve.
Returns
- Task<ConfigPumps>
A ConfigPumps instance if a matching configuration is found; otherwise,
null.
InsertPumpConfig(ConfigPumps)
Inserts a new pump configuration into the repository, records an audit log entry for the operation, and returns the inserted configuration. If the configuration cannot be retrieved after insertion or any exception occurs, the error is logged and the method returns null.
public Task<ConfigPumps?> InsertPumpConfig(ConfigPumps pumpConfig)
Parameters
pumpConfigConfigPumpsThe pump configuration to insert.
Returns
- Task<ConfigPumps>
The inserted ConfigPumps on success; otherwise,
nullwhen an error occurs during the operation.
Exceptions
- ConflictException
Thrown when the inserted configuration cannot be found in the repository after insertion.
Map(PumpObservation)
Maps a PumpObservation using its alarm type configuration. Returns the original observation unchanged when configuration-based pump mapping is not required or when no matching configuration is found.
public Task<PumpObservation> Map(PumpObservation obs)
Parameters
obsPumpObservationThe pump observation to map, containing the alarm type used for configuration lookup.
Returns
- Task<PumpObservation>
The mapped pump observation, or the original observation when mapping is skipped or the configuration lookup yields no result.
RetentionActions(PumpObservation)
Determines the retention actions to apply for a pump observation based on its configuration. When a retention policy is configured, returns the configured policy and its value; otherwise, falls back to NoDelete with a null value.
public Task<ObservatitonRetentionResult?> RetentionActions(PumpObservation obs)
Parameters
obsPumpObservationThe pump observation for which to evaluate the retention policy.
Returns
- Task<ObservatitonRetentionResult>
A task containing the retention result with the applicable policy and associated value, or a default NoDelete result when no policy is configured.
UpdatePumpConfig(ConfigPumps)
Updates the pump configuration in the repository and records an audit log of the change. Throws a ConflictException if the update operation returns null.
public Task<ConfigPumps?> UpdatePumpConfig(ConfigPumps pumpConfig)
Parameters
pumpConfigConfigPumpsThe pump configuration to update, identified by its Id.
Returns
- Task<ConfigPumps>
A task representing the asynchronous operation, containing the updated ConfigPumps.
Exceptions
- ConflictException
Thrown when the update operation fails.