# 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
  object
  MongoRepository<ChartConfig>
  DisplayChartConfigRepository

Implements
  IDisplayChartConfigRepository
  IMongoRepository<ChartConfig>

Inherited Members
  MongoRepository<ChartConfig>.Db
  MongoRepository<ChartConfig>.Collection
  MongoRepository<ChartConfig>.InsertOneAsync(ChartConfig)
  MongoRepository<ChartConfig>.UpdateOneAsync(ObjectId, ChartConfig)
  MongoRepository<ChartConfig>.DeleteAsync(ObjectId)
  MongoRepository<ChartConfig>.CreateIndexes()
  MongoRepository<ChartConfig>.InsertInitialLoad()
  MongoRepository<ChartConfig>.InsertManyAsync(List<ChartConfig>)
  MongoRepository<ChartConfig>.UpdateManyObjectIdAsync(string, ObjectId, ObjectId)
  MongoRepository<ChartConfig>.DeleteAsync(string)
  MongoRepository<ChartConfig>.CollectionExists(string)
  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

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

`database` IMongoDatabase

  The MongoDB database instance.

`apiSettings` ApiSettings

  The API settings instance.

`logger` ILogger<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

`configId` ObjectId

  ChartConfig Id to be deleted

#### Returns

Task<ChartConfig>

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

`configId` ObjectId

  The 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

`config` ChartConfig

  The 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

`config` ChartConfig

  The ChartConfig object containing the updated data.

#### Returns

Task<UpdateResponse<ChartConfig>>

  An UpdateResponse object containing the number of changes made and the updated ChartConfig document.