# Class DisplayConfigService

Namespace
  adas_core.Application.Services

Assembly
  adas-core.Application.dll

    public class DisplayConfigService : IDisplayConfigService

Inheritance
  object
  DisplayConfigService

Implements
  IDisplayConfigService

Inherited Members
  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

### DisplayConfigService(IDisplayConfigRepository, Lazy<IDisplayService>, ISubscribersService, IClientMessageService, IHttpContextAccessor, ILocalAuditService, IMasterListServiceFactory, IDisplayCardConfigRepository, IDisplayDetailConfigRepository, IDisplayChartConfigRepository)

    public DisplayConfigService(IDisplayConfigRepository displayConfigRepository, Lazy<IDisplayService> displayService, ISubscribersService subscribersService, IClientMessageService clientMessageService, IHttpContextAccessor httpContextAccessor, ILocalAuditService auditService, IMasterListServiceFactory masterListServiceFactory, IDisplayCardConfigRepository displayCardConfigRepository, IDisplayDetailConfigRepository displayDetailConfigRepository, IDisplayChartConfigRepository displayChartRepository)

#### Parameters

`displayConfigRepository` IDisplayConfigRepository
`displayService` Lazy<IDisplayService>
`subscribersService` ISubscribersService
`clientMessageService` IClientMessageService
`httpContextAccessor` IHttpContextAccessor
`auditService` ILocalAuditService
`masterListServiceFactory` IMasterListServiceFactory
`displayCardConfigRepository` IDisplayCardConfigRepository
`displayDetailConfigRepository` IDisplayDetailConfigRepository
`displayChartRepository` IDisplayChartConfigRepository

## Methods

### DeleteChartConfig(ObjectId)

Deletes the chart configuration identified by the given display object ID. If the repository deletion succeeds, the deleted chart configuration is updated and the method returns `true`; otherwise, it returns `false`.

    public Task<bool> DeleteChartConfig(ObjectId objectIdConfigDisplay)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The object ID of the chart configuration display to delete.

#### Returns

Task<bool>

  `true` if the chart configuration was successfully deleted; `false` if no matching configuration was found.

### DeleteDisplayConfig(ObjectId)

Deletes a display configuration by its identifier. When displays are still associated with the configuration, they are reassigned to a default configuration for the same type before deletion, and an audit log entry is recorded on success.

    public Task<bool> DeleteDisplayConfig(ObjectId objectIdConfigDisplay)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The identifier of the display configuration to delete.

#### Returns

Task<bool>

  A task that resolves to `true` if the configuration was successfully deleted; otherwise, `false`.

#### Exceptions

ConflictException

  Thrown when no default configuration is found for the related display type, or when reassigning a display to the default configuration fails.

### GetAll()

Retrieves all display configurations from the repository and enriches each one with its minimal display section. Configurations for which the minimal display section cannot be resolved are excluded from the result.

    public Task<List<DisplayConfig>> GetAll()

#### Returns

Task<List<DisplayConfig>>

  A task that represents the asynchronous operation. The task result contains a list of enriched DisplayConfig items, omitting any entries that could not be enriched.

### GetAllCompact()

Asynchronously retrieves a compact list of all display configurations from the repository.

    public Task<List<DisplayConfigMinimalResponse>> GetAllCompact()

#### Returns

Task<List<DisplayConfigMinimalResponse>>

  A task that represents the asynchronous operation, containing a list of DisplayConfigMinimalResponse objects representing the compact display configuration data.

### GetAllCompactPaginated(PaginationFilter)

Retrieves a paginated list of display configurations in a compact form, including a flag indicating whether each configuration is currently in use. Applies server-side pagination using the provided filter and maps each result to a DisplayConfigMinimalResponse enriched with its usage status.

    public Task<PaginationResponse<DisplayConfigMinimalResponse>> GetAllCompactPaginated(PaginationFilter filter)

#### Parameters

`filter` PaginationFilter

  The pagination filter containing the page number, page size, and any filtering criteria used to retrieve and paginate the display configurations.

#### Returns

Task<PaginationResponse<DisplayConfigMinimalResponse>>

  A task that represents the asynchronous operation, containing a PaginationResponse<T> with the compact display configurations, current page metadata, and total document count.

### GetById(ObjectId)

Retrieves a DisplayConfig by its identifier and enriches it with minimal display section data. Throws a NotFoundException if no configuration is found for the given id.

    public Task<DisplayConfig> GetById(ObjectId id)

#### Parameters

`id` ObjectId

  The unique identifier of the display configuration to retrieve.

#### Returns

Task<DisplayConfig>

  The display configuration with the minimal display section applied.

#### Exceptions

NotFoundException

  Thrown when no display configuration exists for the specified `id`.

### GetById(ObjectId?, ObjectId, DisplayType)

Retrieves a DisplayConfig by its identifier, falling back to the default configuration for the given unit and display type when the identifier is not provided or not found. When both a configuration by id and a default configuration are found, the two are merged and the merged result is returned.

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

#### Parameters

`configId` ObjectId?

  The optional configuration identifier. When null, only the default configuration is returned.

`unitId` ObjectId

  The unit identifier used to look up the default configuration.

`displayType` DisplayConfigEnums.DisplayType

  The display type used to look up the default configuration.

#### Returns

Task<DisplayConfig>

  The current configuration, the default configuration, the merged configuration, or null when neither is available.

### GetByType(DisplayType)

Retrieves display configurations matching the specified display type and enriches each one with its minimal display section. Configurations for which the enrichment returns null are excluded from the result list.

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

#### Parameters

`type` DisplayConfigEnums.DisplayType

  The display type used to filter the configurations.

#### Returns

Task<List<DisplayConfig>>

  A list of enriched display configurations; entries whose display section could not be resolved are omitted.

### GetCardConfigAll()

Asynchronously retrieves all card configurations from the display card config repository.

    public Task<List<CardConfig>> GetCardConfigAll()

#### Returns

Task<List<CardConfig>>

  A task that represents the asynchronous operation, containing a list of all CardConfig entities.

### GetCardConfigById(ObjectId)

Retrieves a card configuration by its unique identifier from the display card configuration repository.

    public Task<CardConfig?> GetCardConfigById(ObjectId id)

#### Parameters

`id` ObjectId

  The unique identifier of the card configuration to retrieve.

#### Returns

Task<CardConfig>

  The matching CardConfig if found; otherwise, `null`.

### GetChartConfig(ObjectId)

Retrieves a chart configuration by its unique identifier from the display chart repository.

    public Task<ChartConfig?> GetChartConfig(ObjectId objectIdConfigChart)

#### Parameters

`objectIdConfigChart` ObjectId

  The unique identifier of the chart configuration to retrieve.

#### Returns

Task<ChartConfig>

  A task that represents the asynchronous operation. The task result contains the ChartConfig if found; otherwise, `null`.

### GetDefaultConfig(DisplayType)

Retrieves the default DisplayConfig for the specified display type by delegating to the underlying repository. Returns null when no default configuration exists for the given type.

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

#### Parameters

`type` DisplayConfigEnums.DisplayType

  The display type used to look up the default configuration.

#### Returns

Task<DisplayConfig>

  A DisplayConfig representing the default configuration for the specified type, or null if no default is found.

### GetDisplayConfigLocations(ObjectId)

Retrieves the list of display configuration locations associated with the specified configuration display identifier.

    public Task<List<DisplayConfigLocationDto>> GetDisplayConfigLocations(ObjectId objectIdConfigDisplay)

#### Parameters

`objectIdConfigDisplay` ObjectId

  The identifier of the configuration display whose locations are being retrieved.

#### Returns

Task<List<DisplayConfigLocationDto>>

  A task that returns a list of DisplayConfigLocationDto items for the given configuration display.

### InsertCardConfig(CreateDisplayConfigCardDto)

Inserts a new card configuration and optionally links it to an existing display configuration by updating the card config id and broadcasting the change.

    public Task<CardConfig?> InsertCardConfig(CreateDisplayConfigCardDto updateDisplayConfigNameDto)

#### Parameters

`updateDisplayConfigNameDto` CreateDisplayConfigCardDto

  The DTO containing the card configuration to insert and, optionally, the display configuration id to associate it with.

#### Returns

Task<CardConfig>

  The inserted CardConfig, or `null` when the provided card configuration is null.

### InsertCardDetailConfig(CreateDisplayConfigCardDto)

Inserts a new card detail configuration and optionally links it to an existing display configuration, broadcasting the change when the link is successfully established.

    public Task<CardDetailsConfig?> InsertCardDetailConfig(CreateDisplayConfigCardDto updateDisplayConfigNameDto)

#### Parameters

`updateDisplayConfigNameDto` CreateDisplayConfigCardDto

  The DTO containing the detail configuration to insert and, optionally, the ID of the display configuration to associate it with.

#### Returns

Task<CardDetailsConfig>

  The newly inserted CardDetailsConfig, or `null` when no detail configuration is provided in the DTO.

### InsertChartConfig(CreateDisplayConfigCardDto)

Inserts a new chart configuration and, when a display configuration identifier is provided, links the inserted chart to that display configuration and broadcasts the update.

    public Task<ChartConfig?> InsertChartConfig(CreateDisplayConfigCardDto updateDisplayConfigNameDto)

#### Parameters

`updateDisplayConfigNameDto` CreateDisplayConfigCardDto

  The data transfer object containing the chart configuration to insert and, optionally, the target display configuration identifier.

#### Returns

Task<ChartConfig>

  The inserted ChartConfig, or `null` if the supplied chart configuration is `null`.

### InsertOne(DisplayConfig)

Inserts a new display configuration into the repository while recording an audit log entry for the operation.

    public Task<DisplayConfig?> InsertOne(DisplayConfig config)

#### Parameters

`config` DisplayConfig

  The display configuration to insert.

#### Returns

Task<DisplayConfig>

  The inserted display configuration, or null if no entity was returned by the repository.

### InsertOneMinimal(CreateDisplayConfigDto)

Inserts a minimal display configuration, creating a DisplayNurse instance when the type is DisplayNurse and a base DisplayConfig otherwise, while recording an audit log for the creation.

    public Task<DisplayConfig?> InsertOneMinimal(CreateDisplayConfigDto config)

#### Parameters

`config` CreateDisplayConfigDto

  The DTO containing the hospital and display type used to build the new configuration entity.

#### Returns

Task<DisplayConfig>

  The inserted DisplayConfig entity, or `null` if the repository did not return a result.

### InsertOneTest()

Inserts test records for the DisplayNurse and SmartDisplay display configuration types into the repository and returns the inserted DisplayNurse record.

    public Task<DisplayConfig> InsertOneTest()

#### Returns

Task<DisplayConfig>

  The inserted DisplayConfig instance of type DisplayNurse.

### InsertOneWithTemplate(string, DisplayType, string?)

Creates a new display configuration by cloning an existing template identified by its object ID, applying the specified hospital and display type, and inserting it into the data store. Returns `null` when the object ID cannot be parsed, the template cannot be retrieved, the retrieved template does not match the requested display type, or the display type is not one of the handled cases.

    public Task<DisplayConfig?> InsertOneWithTemplate(string objectId, DisplayConfigEnums.DisplayType configType, string? configHospital)

#### Parameters

`objectId` string

  The object ID of the existing template used as the base for the new configuration.

`configType` DisplayConfigEnums.DisplayType

  The display type of the configuration to create; determines which template subtype is expected and produced.

`configHospital` string

  The hospital to associate with the newly created configuration.

#### Returns

Task<DisplayConfig>

  The inserted DisplayConfig when the template is found and matches the requested type; otherwise, `null`.

### UpdateBaseConfig(DisplayConfig)

Updates the base display configuration and records an audit log comparing the previous and updated configurations.

    public Task<bool> UpdateBaseConfig(DisplayConfig baseConfig)

#### Parameters

`baseConfig` DisplayConfig

  The display configuration containing the updated values, identified by its Id.

#### Returns

Task<bool>

  A task that represents the asynchronous operation. The result indicates whether the update was successful.

#### Exceptions

NotFoundException

  Thrown when the display configuration with the specified identifier does not exist before or after the update.

### UpdateCardConfig(CardConfig)

Updates an existing card configuration. When the update is successful, propagates the new configuration to related rotating display configs by refreshing their nurse data, and broadcasts the card display config update to all associated displays.

    public Task<bool> UpdateCardConfig(CardConfig baseConfig)

#### Parameters

`baseConfig` CardConfig

  The card configuration to update.

#### Returns

Task<bool>

  True if the update was applied (repository reported changes); otherwise, false.

### UpdateChartConfig(ChartConfig)

Updates an existing chart configuration in the repository and returns whether the operation modified any records.

    public Task<bool> UpdateChartConfig(ChartConfig baseConfig)

#### Parameters

`baseConfig` ChartConfig

  The chart configuration to be updated.

#### Returns

Task<bool>

  A task that resolves to `true` if the update changed at least one record; otherwise, `false`.

### UpdateConfig(ObjectId, object)

Updates a display configuration, dispatching to a type-specific update path for SmartDisplay or DisplayNurse, broadcasting the change and writing an audit log when the update succeeds.

    public Task<DisplayConfig?> UpdateConfig(ObjectId displayConfigId, object newDisplayConfig)

#### Parameters

`displayConfigId` ObjectId

  The identifier of the display configuration to update.

`newDisplayConfig` object

  The new configuration payload, deserialized internally into the appropriate DTO based on its `Type`.

#### Returns

Task<DisplayConfig>

  The updated DisplayConfig when the corresponding update succeeds; otherwise the method throws.

#### Exceptions

NotFoundException

  Thrown when the configuration's `Type` is not handled, or when the underlying update returns no result.

### UpdateConfigColor(ObjectId, ColorConfig)

Updates the color configuration of a display, initializing an empty color configuration when none exists, and records an audit log of the change.

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

#### Parameters

`objectIdConfigDisplay` ObjectId

  The identifier of the display configuration to update.

`colorConfig` ColorConfig

  The new color configuration to apply to the display.

#### Returns

Task<bool>

  True if the color configuration was updated successfully; otherwise, false.

#### Exceptions

NotFoundException

  Thrown when the display configuration identified by `objectIdConfigDisplay` cannot be found before or after the update.

### UpdateDetailConfig(CardDetailsConfig)

Updates an existing card detail configuration and propagates the change by broadcasting an update event to all related displays. Returns `true` if the update modified at least one record, otherwise `false`.

    public Task<bool> UpdateDetailConfig(CardDetailsConfig baseConfig)

#### Parameters

`baseConfig` CardDetailsConfig

  The card detail configuration to update, identified by its `Id`.

#### Returns

Task<bool>

  A task that resolves to `true` when the update affected one or more records; `false` when no changes were made.

### UpdateDisplayConfigHospitalName(ObjectId, string)

Updates the hospital name of an existing display configuration and records an audit log entry comparing the previous and updated values.

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

#### Parameters

`objectIdConfigDisplay` ObjectId

  The identifier of the display configuration to update.

`name` string

  The new hospital name to apply to the display configuration.

#### Returns

Task<bool>

  A task that resolves to `true` if the update was successful; otherwise, `false`.

#### Exceptions

NotFoundException

  Thrown when the display configuration identified by `objectIdConfigDisplay` cannot be found before or after the update.

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

Updates the list of fields associated with a display configuration identified by the specified object ID.

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

#### Parameters

`objectIdConfigDisplay` ObjectId

  The unique identifier of the display configuration whose field list is being updated.

`fields` List<Field>

  The collection of fields to be associated with the display configuration.

#### Returns

Task<bool>

  A task that represents the asynchronous operation, containing a boolean value indicating whether the update was successful.

### UpdateHeaderConfig(ObjectId, HeaderConfig)

Updates the header configuration of a display configuration record and creates an audit log entry capturing the previous and updated values.

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

#### Parameters

`objectIdConfigDisplay` ObjectId

  The unique identifier of the display configuration to update.

`headerConfig` HeaderConfig

  The new header configuration to apply to the display configuration.

#### Returns

Task<bool>

  A task that represents the asynchronous operation. The task result is `true` if the update was successful; otherwise, `false`.

#### Exceptions

NotFoundException

  Thrown when the display configuration is not found before the update, or when the updated display configuration cannot be retrieved afterwards.

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

Updates the home banner configuration for the specified display configuration and records an audit log comparing the old and new states.

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

#### Parameters

`objectIdConfigDisplay` ObjectId

  The identifier of the display configuration to update.

`bannerItems` List<BannerItem>

  The list of banner items to set for the home banner.

#### Returns

Task<bool>

  A task that resolves to `true` if the update succeeds; otherwise, `false`.

#### Exceptions

NotFoundException

  Thrown when the display configuration cannot be found before or after the update.