# Class ConfigPumpsService

Namespace
  adas_core.Application.Services

Assembly
  adas-core.Application.dll

    public class ConfigPumpsService : IConfigPumpsService

Inheritance
  object
  ConfigPumpsService

Implements
  IConfigPumpsService

Inherited Members
  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?)

## Constructors

### ConfigPumpsService(IConfigPumpsRepository, IOptions<ApiSettings>, ILogger<ConfigPumpsService>, IHttpContextAccessor, ILocalAuditService)

    public ConfigPumpsService(IConfigPumpsRepository configPumpsRepository, IOptions<ApiSettings> apiSettings, ILogger<ConfigPumpsService> logger, IHttpContextAccessor httpContextAccessor, ILocalAuditService auditService)

#### Parameters

`configPumpsRepository` IConfigPumpsRepository
`apiSettings` IOptions<ApiSettings>
`logger` ILogger<ConfigPumpsService>
`httpContextAccessor` IHttpContextAccessor
`auditService` ILocalAuditService

## 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

`config` ConfigPumps

  The ConfigPumps instance representing the pump configuration to delete.

#### Returns

Task<bool>

  A task that resolves to `true` when the configuration is deleted and the audit log is recorded; `false` when 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 `null` if 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 `null` when 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

`id` string

  The unique identifier of the config pump to look up.

#### Returns

Task<List<ConfigPumpItem>>

  A task that resolves to the list of ConfigPumpItem entries, or `null` if 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

`id` string

  The 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

`pumpConfig` ConfigPumps

  The pump configuration to insert.

#### Returns

Task<ConfigPumps>

  The inserted ConfigPumps on success; otherwise, `null` when 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

`obs` PumpObservation

  The 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

`obs` PumpObservation

  The 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

`pumpConfig` ConfigPumps

  The 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.