Class DisplayChartConfigRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Repository for managing ChartConfig in MongoDB. Provides methods to retrieve and manipulate ChartConfig data.
public class DisplayChartConfigRepository : MongoRepository<ChartConfig>, IDisplayChartConfigRepository, IMongoRepository<ChartConfig>
- Inheritance
-
DisplayChartConfigRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
DisplayChartConfigRepository(IMongoDatabase, ApiSettings, ILogger<DisplayChartConfigRepository>)
Initializes a new instance of the DisplayChartConfigRepository class with the specified API settings, MongoDB database, and logger.
public DisplayChartConfigRepository(IMongoDatabase database, ApiSettings apiSettings, ILogger<DisplayChartConfigRepository> logger)
Parameters
databaseIMongoDatabaseThe MongoDB database instance.
apiSettingsApiSettingsThe API settings instance.
loggerILogger<DisplayChartConfigRepository>The logger instance.
Methods
DeleteOne(ObjectId)
Deletes a ChartConfig document from the MongoDB collection based on the provided unique identifier.
public Task<ChartConfig?> DeleteOne(ObjectId configId)
Parameters
configIdObjectIdChartConfig Id to be deleted
Returns
GetAll()
Retrieves all ChartConfig documents from the MongoDB collection. This method returns a list of ChartConfig objects representing all the configurations stored in the database.
public Task<List<ChartConfig>> GetAll()
Returns
- Task<List<ChartConfig>>
A list of ChartConfig objects representing all the configurations stored in the database.
GetById(ObjectId)
Retrieves a ChartConfig document from the MongoDB collection by its unique identifier. This method takes an ObjectId as a parameter and returns the corresponding ChartConfig object if found, or null if no matching document is found.
public Task<ChartConfig?> GetById(ObjectId configId)
Parameters
configIdObjectIdThe unique identifier of the ChartConfig document.
Returns
- Task<ChartConfig>
The ChartConfig object if found, or null if no matching document is found.
GetCollectionName()
Gets the name of the MongoDB collection for ChartConfig. This method retrieves the collection name from the API settings.
public override string GetCollectionName()
Returns
- string
The name of the MongoDB collection for ChartConfig.
InsertOneAsyncAndReturn(ChartConfig)
Inserts a new ChartConfig document into the MongoDB collection and returns the inserted document. This method takes a ChartConfig object as a parameter, inserts it into the database, and returns the same object if the insertion is successful. If an error occurs during the insertion process, it logs the error and returns null.
public Task<ChartConfig?> InsertOneAsyncAndReturn(ChartConfig config)
Parameters
configChartConfigThe ChartConfig object to be inserted into the MongoDB collection.
Returns
- Task<ChartConfig>
The inserted ChartConfig object if successful, or null if an error occurs.
UpdateOne(ChartConfig?)
Updates an existing ChartConfig document in the MongoDB collection based on the provided ChartConfig object. This method takes a ChartConfig object as a parameter, identifies the document to be updated using the Id property, and updates the BaseConfig, AxesConfig, and SeriesConfig fields of the matching document. It returns an UpdateResponse object containing the number of changes made and the updated ChartConfig document. If an error occurs during the update process, it logs the error and returns an UpdateResponse with zero changes and null data.
public Task<UpdateResponse<ChartConfig?>> UpdateOne(ChartConfig? config)
Parameters
configChartConfigThe ChartConfig object containing the updated data.
Returns
- Task<UpdateResponse<ChartConfig>>
An UpdateResponse object containing the number of changes made and the updated ChartConfig document.