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
-
DisplayConfigRepository
- Implements
- Inherited Members
- Extension Methods
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
databaseIMongoDatabaseThe MongoDB database instance.
apiSettingsApiSettingsAPI settings containing collection names configuration.
loggerILogger<DisplayConfigRepository>Logger for repository operations.
unitRepositoryIUnitRepositoryRepository 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
displayConfigIdObjectId?The ObjectId of the display configuration to update.
newChartIdToAddObjectIdThe new chart configuration ID to add.
Returns
DeleteDisplayConfig(ObjectId)
Deletes a display configuration by its ID.
public Task<DisplayConfig?> DeleteDisplayConfig(ObjectId objectIdConfigDisplay)
Parameters
objectIdConfigDisplayObjectIdThe 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
cardConfigIdObjectIdThe 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
cardConfigIdObjectIdThe 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
baseConfigIdObjectIdThe 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
filterPaginationFilterThe 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
idObjectIdThe 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
typeDisplayConfigEnums.DisplayTypeThe 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
objectIdConfigChartObjectIdThe 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
typeDisplayConfigEnums.DisplayTypeThe 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
unitIdObjectIdThe ObjectId of the unit.
displayTypeDisplayConfigEnums.DisplayTypeThe 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
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
configDisplayConfigThe DisplayConfig to insert.
Returns
UpdateBaseConfig(ObjectId, DisplayConfig)
Updates the base configuration for a specific display.
public Task<bool> UpdateBaseConfig(ObjectId objectIdConfigDisplay, DisplayConfig baseConfig)
Parameters
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
baseConfigDisplayConfigThe base DisplayConfig with updated values.
Returns
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
displayConfigIdObjectId?The ObjectId of the display configuration to update.
resultIdObjectId?The new card configuration ID to set.
Returns
UpdateConfigColor(ObjectId, ColorConfig)
Updates the color configuration for a specific display.
public Task<bool> UpdateConfigColor(ObjectId objectIdConfigDisplay, ColorConfig colorConfig)
Parameters
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
colorConfigColorConfigThe new ColorConfig to apply.
Returns
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
deletedIdObjectIdThe 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
displayConfigIdObjectId?The ObjectId of the display configuration to update.
resultIdObjectId?The new detail configuration ID to set.
Returns
UpdateDisplayConfigHospitalName(ObjectId, string)
Updates the hospital name for a specific display configuration.
public Task<bool> UpdateDisplayConfigHospitalName(ObjectId objectIdConfigDisplay, string name)
Parameters
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
namestringThe new hospital name.
Returns
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
displayConfigIdObjectIdThe ObjectId of the display configuration to update.
newDisplayConfigDisplayNurseDtoThe new DisplayNurseDto configuration to apply.
nurseObsList<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
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
fieldsList<Field>The new list of fields to set.
Returns
UpdateHeaderConfig(ObjectId, HeaderConfig)
Updates the header configuration for a specific display.
public Task<bool> UpdateHeaderConfig(ObjectId objectIdConfigDisplay, HeaderConfig headerConfig)
Parameters
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
headerConfigHeaderConfigThe new HeaderConfig to apply.
Returns
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
objectIdConfigDisplayObjectIdThe ObjectId of the display configuration to update.
bannerItemsList<BannerItem>The list of banner items to set.
Returns
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
displayConfigIdObjectIdThe ObjectId of the display configuration to update.
newDisplayConfigSmartDisplayThe new SmartDisplay configuration to apply.
Returns
- Task<SmartDisplay>
The updated SmartDisplay configuration, or null if update fails.