# Class DisplayConfigRepository

Namespace
  adas_core.Infrastructure.Repositories

Assembly
  adas-core.Infrastructure.dll

Repository implementation for managing DisplayConfig entities in MongoDB. Provides CRUD operations and specialized queries for display configurations.

    public class DisplayConfigRepository : MongoRepository<DisplayConfig>, IDisplayConfigRepository, IMongoRepository<DisplayConfig>

Inheritance
  object
  MongoRepository<DisplayConfig>
  DisplayConfigRepository

Implements
  IDisplayConfigRepository
  IMongoRepository<DisplayConfig>

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

### DisplayConfigRepository(IMongoDatabase, ApiSettings, ILogger<DisplayConfigRepository>, IUnitRepository)

Initializes a new instance of the DisplayConfigRepository.

    public DisplayConfigRepository(IMongoDatabase database, ApiSettings apiSettings, ILogger<DisplayConfigRepository> logger, IUnitRepository unitRepository)

#### Parameters

`database` IMongoDatabase

  The MongoDB database instance.

`apiSettings` ApiSettings

  API settings containing collection names configuration.

`logger` ILogger<DisplayConfigRepository>

  Logger for repository operations.

`unitRepository` IUnitRepository

  Repository for unit-related operations.

## Methods

### AddChartId(ObjectId?, ObjectId)

Adds a new chart configuration ID to a smart display's chart config list.

    public Task<bool> AddChartId(ObjectId? displayConfigId, ObjectId newChartIdToAdd)

#### Parameters

`displayConfigId` ObjectId?

  The ObjectId of the display configuration to update.

`newChartIdToAdd` ObjectId

  The new chart configuration ID to add.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

### DeleteDisplayConfig(ObjectId)

Deletes a display configuration by its ID.

    public Task<DisplayConfig?> DeleteDisplayConfig(ObjectId objectIdConfigDisplay)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to delete.

#### Returns

Task<DisplayConfig>

  The deleted DisplayConfig, or null if not found.

### GetAll()

Retrieves all display configurations from the database.

    public Task<List<DisplayConfig>> GetAll()

#### Returns

Task<List<DisplayConfig>>

  A list of all DisplayConfig entities.

### GetAllByCardConfigId(ObjectId)

Retrieves all display configuration IDs associated with a specific card configuration.

    public Task<List<ObjectId>> GetAllByCardConfigId(ObjectId cardConfigId)

#### Parameters

`cardConfigId` ObjectId

  The ObjectId of the card configuration.

#### Returns

Task<List<ObjectId>>

  A list of ObjectIds for display configurations using the specified card config.

### GetAllByCardConfigIdAndRotating(ObjectId)

Retrieves all display configuration IDs associated with a card config, including rotating layouts.

    public Task<List<ObjectId>> GetAllByCardConfigIdAndRotating(ObjectId cardConfigId)

#### Parameters

`cardConfigId` ObjectId

  The ObjectId of the card configuration.

#### Returns

Task<List<ObjectId>>

  A list of ObjectIds for display configurations using the specified card config in main or rotating layout.

### GetAllByCardDetailConfigId(ObjectId)

Retrieves all display configuration IDs associated with a specific detail configuration.

    public Task<List<ObjectId>> GetAllByCardDetailConfigId(ObjectId baseConfigId)

#### Parameters

`baseConfigId` ObjectId

  The ObjectId of the detail configuration.

#### Returns

Task<List<ObjectId>>

  A list of ObjectIds for display configurations using the specified detail config.

### GetAllCompact()

Retrieves all display configurations in compact format (minimal response).

    public Task<List<DisplayConfigMinimalResponse>> GetAllCompact()

#### Returns

Task<List<DisplayConfigMinimalResponse>>

  A list of DisplayConfigMinimalResponse containing Id, Hospital, and Type.

### GetAllPaginated(PaginationFilter)

Retrieves paginated display configurations with optional filtering.

    public IFindFluent<DisplayConfig, DisplayConfigSummary> GetAllPaginated(PaginationFilter filter)

#### Parameters

`filter` PaginationFilter

  The pagination and filtering parameters.

#### Returns

IFindFluent<DisplayConfig, DisplayConfigSummary>

  A fluent queryable for DisplayConfigSummary results.

#### Exceptions

BadRequestException

  Thrown when the text filter exceeds 100 characters.

### GetById(ObjectId)

Retrieves a display configuration by its ID with related configurations populated. Performs aggregation to include CardConfig, DetailConfig, ChartConfig, and rotating layout data.

    public Task<DisplayConfig?> GetById(ObjectId id)

#### Parameters

`id` ObjectId

  The ObjectId of the display configuration to retrieve.

#### Returns

Task<DisplayConfig>

  The DisplayConfig with related data, or null if not found.

### GetByType(DisplayType)

Retrieves all display configurations of a specific type.

    public Task<List<DisplayConfig>> GetByType(DisplayConfigEnums.DisplayType type)

#### Parameters

`type` DisplayConfigEnums.DisplayType

  The display type to filter by.

#### Returns

Task<List<DisplayConfig>>

  A list of DisplayConfig entities matching the specified type.

### GetChartConfig(ObjectId)

Gets a chart configuration by ID. This method is not implemented.

    public Task<ChartConfig> GetChartConfig(ObjectId objectIdConfigChart)

#### Parameters

`objectIdConfigChart` ObjectId

  The ObjectId of the chart configuration.

#### Returns

Task<ChartConfig>

  Always throws NotImplementedException.

#### Exceptions

NotImplementedException

  This method is not implemented.

### GetCollectionName()

Gets the name of the collection for display configurations.

    public override string GetCollectionName()

#### Returns

string

  The collection name from API settings.

### GetDefault(DisplayType)

Retrieves the default display configuration for a given type. Default configurations are identified by having "Default" as the hospital name.

    public Task<DisplayConfig?> GetDefault(DisplayConfigEnums.DisplayType type)

#### Parameters

`type` DisplayConfigEnums.DisplayType

  The display type to search for.

#### Returns

Task<DisplayConfig>

  The default DisplayConfig for the specified type, or null if not found.

### GetDefaultByUnitIdAndType(ObjectId, DisplayType)

Gets the default display configuration for a unit based on its ID and display type.

    public Task<DisplayConfig?> GetDefaultByUnitIdAndType(ObjectId unitId, DisplayConfigEnums.DisplayType displayType)

#### Parameters

`unitId` ObjectId

  The ObjectId of the unit.

`displayType` DisplayConfigEnums.DisplayType

  The type of display configuration to retrieve.

#### Returns

Task<DisplayConfig>

  The default DisplayConfig for the unit, or null if not found.

### InsertInitialLoad()

Performs initial data load by creating default configurations for each display type if they don't exist.

    public override sealed Task InsertInitialLoad()

#### Returns

Task

#### Remarks

This method runs on application startup to ensure default configurations exist for:

- DisplayNurse
- SmartDisplay
- StandarDisplay

### InsertOneAsyncAndReturn(DisplayConfig)

Inserts a new display configuration and returns the inserted document.

    public Task<DisplayConfig?> InsertOneAsyncAndReturn(DisplayConfig config)

#### Parameters

`config` DisplayConfig

  The DisplayConfig to insert.

#### Returns

Task<DisplayConfig>

### UpdateBaseConfig(ObjectId, DisplayConfig)

Updates the base configuration for a specific display.

    public Task<bool> UpdateBaseConfig(ObjectId objectIdConfigDisplay, DisplayConfig baseConfig)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`baseConfig` DisplayConfig

  The base DisplayConfig with updated values.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

#### Exceptions

Exception

  Throws an exception if MongoDB update fails.

### UpdateCardConfigId(ObjectId?, ObjectId?)

Updates the card configuration ID for a specific display.

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

#### Parameters

`displayConfigId` ObjectId?

  The ObjectId of the display configuration to update.

`resultId` ObjectId?

  The new card configuration ID to set.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

### UpdateConfigColor(ObjectId, ColorConfig)

Updates the color configuration for a specific display.

    public Task<bool> UpdateConfigColor(ObjectId objectIdConfigDisplay, ColorConfig colorConfig)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`colorConfig` ColorConfig

  The new ColorConfig to apply.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

#### Exceptions

Exception

  Throws an exception if MongoDB update fails.

### UpdateDeletedChartConfig(ObjectId)

Removes a deleted chart configuration ID from all display configurations.

    public Task<UpdateResult> UpdateDeletedChartConfig(ObjectId deletedId)

#### Parameters

`deletedId` ObjectId

  The ObjectId of the chart configuration that was deleted.

#### Returns

Task<UpdateResult>

  The MongoDB UpdateResult indicating the number of modified documents.

#### Exceptions

Exception

  Throws an exception if MongoDB operation fails.

### UpdateDetailConfigId(ObjectId?, ObjectId?)

Updates the detail configuration ID for a specific display.

    public Task<bool> UpdateDetailConfigId(ObjectId? displayConfigId, ObjectId? resultId)

#### Parameters

`displayConfigId` ObjectId?

  The ObjectId of the display configuration to update.

`resultId` ObjectId?

  The new detail configuration ID to set.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

### UpdateDisplayConfigHospitalName(ObjectId, string)

Updates the hospital name for a specific display configuration.

    public Task<bool> UpdateDisplayConfigHospitalName(ObjectId objectIdConfigDisplay, string name)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`name` string

  The new hospital name.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

### UpdateDisplayNurse(ObjectId, DisplayNurseDto?, List<string>)

Updates the nurse display configuration with additional observation fields.

    public Task<DisplayNurse?> UpdateDisplayNurse(ObjectId displayConfigId, DisplayNurseDto? newDisplayConfig, List<string> nurseObs)

#### Parameters

`displayConfigId` ObjectId

  The ObjectId of the display configuration to update.

`newDisplayConfig` DisplayNurseDto

  The new DisplayNurseDto configuration to apply.

`nurseObs` List<string>

  List of observation names to mark as "last".

#### Returns

Task<DisplayNurse>

  The updated DisplayNurse configuration, or null if update fails.

### UpdateFieldList(ObjectId, List<Field>)

Updates the field list for a specific display configuration.

    public Task<bool> UpdateFieldList(ObjectId objectIdConfigDisplay, List<Field> fields)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`fields` List<Field>

  The new list of fields to set.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

### UpdateHeaderConfig(ObjectId, HeaderConfig)

Updates the header configuration for a specific display.

    public Task<bool> UpdateHeaderConfig(ObjectId objectIdConfigDisplay, HeaderConfig headerConfig)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`headerConfig` HeaderConfig

  The new HeaderConfig to apply.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

#### Exceptions

Exception

  Throws an exception if MongoDB update fails.

### UpdateSetHomeBanner(ObjectId, List<BannerItem>)

Updates the home banner configuration for a specific display.

    public Task<bool> UpdateSetHomeBanner(ObjectId objectIdConfigDisplay, List<BannerItem> bannerItems)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The ObjectId of the display configuration to update.

`bannerItems` List<BannerItem>

  The list of banner items to set.

#### Returns

Task<bool>

  True if the update was successful; otherwise, false.

#### Exceptions

Exception

  Throws an exception if MongoDB update fails.

### UpdateSmartDisplay(ObjectId, SmartDisplay?)

Updates the smart display configuration for a specific display.

    public Task<SmartDisplay?> UpdateSmartDisplay(ObjectId displayConfigId, SmartDisplay? newDisplayConfig)

#### Parameters

`displayConfigId` ObjectId

  The ObjectId of the display configuration to update.

`newDisplayConfig` SmartDisplay

  The new SmartDisplay configuration to apply.

#### Returns

Task<SmartDisplay>

  The updated SmartDisplay configuration, or null if update fails.