Table of Contents

Class DisplayCardConfigRepository

Namespace
adas_core.Infrastructure.Repositories
Assembly
adas-core.Infrastructure.dll

Repository for managing display card configurations in MongoDB. Provides methods to perform CRUD operations on CardConfig documents.

public class DisplayCardConfigRepository : MongoRepository<CardConfig>, IDisplayCardConfigRepository, IMongoRepository<CardConfig>
Inheritance
DisplayCardConfigRepository
Implements
Inherited Members
Extension Methods

Constructors

DisplayCardConfigRepository(IMongoDatabase, ApiSettings, ILogger<DisplayCardConfigRepository>)

Initializes a new instance of the DisplayCardConfigRepository class with the specified MongoDB database, API settings, and logger.

public DisplayCardConfigRepository(IMongoDatabase database, ApiSettings apiSettings, ILogger<DisplayCardConfigRepository> logger)

Parameters

database IMongoDatabase

The MongoDB database instance.

apiSettings ApiSettings

The API settings containing configuration for the repository.

logger ILogger<DisplayCardConfigRepository>

The logger instance for logging repository operations.

Methods

DeleteOne(ObjectId)

Deletes a CardConfig document from the MongoDB collection based on the provided unique identifier.

public Task<CardConfig?> DeleteOne(ObjectId configId)

Parameters

configId ObjectId

The unique identifier of the CardConfig document to delete.

Returns

Task<CardConfig>

A task representing the asynchronous operation, containing the deleted CardConfig document if successful, or null if not found or an error occurs.

GetAll()

Retrieves all CardConfig documents from the MongoDB collection and returns them as a list. Logs any exceptions that occur during the retrieval process.

public Task<List<CardConfig>> GetAll()

Returns

Task<List<CardConfig>>

A task representing the asynchronous operation, containing a list of all CardConfig documents.

GetById(ObjectId)

Retrieves a CardConfig document by its unique identifier from the MongoDB collection. Logs any exceptions that occur during the retrieval process and returns null if an error occurs or if the document is not found.

public Task<CardConfig?> GetById(ObjectId configId)

Parameters

configId ObjectId

The unique identifier of the CardConfig document.

Returns

Task<CardConfig>

A task representing the asynchronous operation, containing the CardConfig document if found, or null if not found or an error occurs.

GetCollectionName()

Gets the name of the MongoDB collection for CardConfig documents, as specified in the API settings.

public override string GetCollectionName()

Returns

string

The name of the MongoDB collection for CardConfig documents.

InsertOneAsyncAndReturn(CardConfig)

Inserts a new CardConfig document into the MongoDB collection and returns the inserted document. Logs any exceptions that occur during the insertion process and returns null if an error occurs.

public Task<CardConfig?> InsertOneAsyncAndReturn(CardConfig config)

Parameters

config CardConfig

The CardConfig document to insert.

Returns

Task<CardConfig>

A task representing the asynchronous operation, containing the inserted CardConfig document if successful, or null if an error occurs.

UpdateCardConfigId(ObjectId?, ObjectId?)

Updates the CardConfig document associated with the specified display configuration ID and result ID.

public Task<object> UpdateCardConfigId(ObjectId? displayConfigId, ObjectId? resultId)

Parameters

displayConfigId ObjectId?

The unique identifier of the display configuration.

resultId ObjectId?

The unique identifier of the result.

Returns

Task<object>

A task representing the asynchronous operation, containing the updated CardConfig document if successful, or null if not found or an error occurs.

Exceptions

NotImplementedException

UpdateOne(CardConfig?)

Updates an existing CardConfig document in the MongoDB collection based on the provided CardConfig object. The method updates the Rows field of the document with the matching Id. It returns an UpdateResponse containing the number of modified documents and the updated document itself. Logs any exceptions that occur during the update process and returns an UpdateResponse with zero changes and null data if an error occurs or if the input config is null.

public Task<UpdateResponse<CardConfig?>> UpdateOne(CardConfig? config)

Parameters

config CardConfig

The CardConfig document to update.

Returns

Task<UpdateResponse<CardConfig>>

A task representing the asynchronous operation, containing an UpdateResponse with the number of modified documents and the updated document.