Table of Contents

Class HistoricalConfigChangesService

Namespace
adas_core.Application.Services
Assembly
adas-core.Application.dll
public class HistoricalConfigChangesService : IHistoricalConfigChangesService
Inheritance
HistoricalConfigChangesService
Implements
Inherited Members
Extension Methods

Constructors

HistoricalConfigChangesService(IHistoricalConfigChangesRepository, ILogger<HistoricalConfigChangesService>, IHttpContextAccessor, ILocalAuditService)

public HistoricalConfigChangesService(IHistoricalConfigChangesRepository historicalConfigChangesRepository, ILogger<HistoricalConfigChangesService> logger, IHttpContextAccessor httpContextAccessor, ILocalAuditService auditService)

Parameters

historicalConfigChangesRepository IHistoricalConfigChangesRepository
logger ILogger<HistoricalConfigChangesService>
httpContextAccessor IHttpContextAccessor
auditService ILocalAuditService

Methods

DeleteHistoricalConfigChange(ObjectId)

Deletes a historical configuration change record by its identifier and creates an audit log entry recording the deletion.

public Task DeleteHistoricalConfigChange(ObjectId id)

Parameters

id ObjectId

The unique identifier of the historical configuration change to delete.

Returns

Task

FindLastConfigChanges(ConfigTypes)

Retrieves the most recent historical configuration change entry for the specified configuration type.

public Task<HistoricalConfigChanges?> FindLastConfigChanges(DisplayConfigEnums.ConfigTypes configType)

Parameters

configType DisplayConfigEnums.ConfigTypes

The configuration type used to look up the last historical change.

Returns

Task<HistoricalConfigChanges>

The most recent HistoricalConfigChanges entry, or null if no changes exist for the given type.

Get(ObjectId)

Retrieves a historical configuration change record by its unique identifier. Returns null when no matching record is found in the repository.

public Task<HistoricalConfigChanges?> Get(ObjectId id)

Parameters

id ObjectId

The unique identifier of the historical configuration change to retrieve.

Returns

Task<HistoricalConfigChanges>

The matching HistoricalConfigChanges record, or null if no record is found.

GetAll()

Retrieves all historical configuration changes from the repository.

public Task<ICollection<HistoricalConfigChanges>> GetAll()

Returns

Task<ICollection<HistoricalConfigChanges>>

A task that represents the asynchronous operation, containing a collection of all HistoricalConfigChanges records.

GetByType(ConfigTypes, int)

Retrieves the most recent historical configuration changes for the specified configuration type, limited to a given number of entries.

public Task<ICollection<HistoricalConfigChanges>> GetByType(DisplayConfigEnums.ConfigTypes type, int num = 10)

Parameters

type DisplayConfigEnums.ConfigTypes

The configuration type used to filter the historical changes.

num int

The maximum number of recent changes to return. Defaults to 10.

Returns

Task<ICollection<HistoricalConfigChanges>>

A collection of the latest HistoricalConfigChanges entries matching the specified type.

GetByUser(string, ConfigTypes?, int)

Retrieves the most recent historical configuration changes for a given user, optionally filtered by configuration type and limited to a specified maximum number of entries.

public Task<ICollection<HistoricalConfigChanges>> GetByUser(string user, DisplayConfigEnums.ConfigTypes? configTypes = null, int num = 10)

Parameters

user string

The identifier of the user whose historical configuration changes are being retrieved.

configTypes DisplayConfigEnums.ConfigTypes?

Optional filter for the configuration type; when null, all configuration types are included.

num int

The maximum number of historical change entries to return. Defaults to 10.

Returns

Task<ICollection<HistoricalConfigChanges>>

A task that represents the asynchronous operation, containing a collection of the user's historical configuration changes.

InsertOne(HistoricalConfigChanges)

Inserts a new historical configuration change record into the repository and creates a corresponding audit log entry. If the repository returns null, a conflict exception is thrown; on failure, the error is logged and null is returned.

public Task<HistoricalConfigChanges?> InsertOne(HistoricalConfigChanges historicalConfigChanges)

Parameters

historicalConfigChanges HistoricalConfigChanges

The historical configuration change entity to insert.

Returns

Task<HistoricalConfigChanges>

The inserted HistoricalConfigChanges entity, or null if the operation fails.

Exceptions

ConflictException

Thrown when the repository returns null after the insert operation.

LogConfigChanged(string, ConfigTypes, string, string)

Asynchronously logs a change to a display configuration, recording the user who made the change, the configuration type, the previous value, and the new value. Logs an error if the insertion fails, or a debug message if it succeeds.

public Task LogConfigChanged(string user, DisplayConfigEnums.ConfigTypes configType, string newConfig, string oldConfig)

Parameters

user string

The username of the user who made the configuration change.

configType DisplayConfigEnums.ConfigTypes

The type of configuration that was changed.

newConfig string

The new configuration value after the change.

oldConfig string

The previous configuration value before the change.

Returns

Task

UpdateHistoricalConfigChange(HistoricalConfigChanges)

Updates an existing historical configuration change record, creating an audit log entry for the change. If the record is not found, a ConflictException is thrown; any other exception is logged and the method returns null.

public Task<HistoricalConfigChanges?> UpdateHistoricalConfigChange(HistoricalConfigChanges historicalConfigChanges)

Parameters

historicalConfigChanges HistoricalConfigChanges

The historical configuration change entity containing the updated values to persist.

Returns

Task<HistoricalConfigChanges>

The updated HistoricalConfigChanges entity on success, or null if an error occurs during the operation.

Exceptions

ConflictException

Thrown when no existing historical configuration change is found with the specified Id.