Class SectionRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Represents a MongoDB repository for Section entities,
implementing the contract defined by ISectionRepository.
public class SectionRepository : MongoRepository<Section>, ISectionRepository, IMongoRepository<Section>
- Inheritance
-
SectionRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
SectionRepository(IOptions<ApiSettings>, IMongoDatabase)
public SectionRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>databaseIMongoDatabase
Methods
FindById(object)
Asynchronously retrieves a Section by its identifier from the collection, returning null when no matching document is found.
public Task<Section?> FindById(object id)
Parameters
idobjectThe identifier of the section to locate.
Returns
FindById(string)
Finds a Section by its unique identifier in the underlying collection.
Returns null when no matching section exists.
public Task<Section?> FindById(string id)
Parameters
idstringThe unique identifier of the section to retrieve.
Returns
FindByLocation(PatientLocation)
Retrieves the active sections associated with the specified patient location by matching the unit name and bed against the section hierarchy. Filtering is performed in memory after retrieving all sections because the underlying query does not support direct filtering on the collection's point of care field. A section is considered matching when its point of care equals the unit name and contains a box with a null point of care for the requested bed, or when it contains a box whose point of care equals the unit name for the requested bed.
public Task<List<Section>> FindByLocation(PatientLocation location)
Parameters
locationPatientLocationThe patient location containing the unit name and bed used to locate the corresponding sections.
Returns
- Task<List<Section>>
A task that represents the asynchronous operation. The task result contains a list of sections matching the provided patient location; an empty list is returned when no matching sections are found.
FindByPointOfCare(string)
Asynchronously retrieves the first Section whose PointOfCare matches the specified value.
public Task<Section?> FindByPointOfCare(string pointOfCare)
Parameters
pointOfCarestringThe point of care identifier used to filter the sections.
Returns
FindBySection(string)
Finds and returns the first Section whose SectionTitle matches the specified section value.
public Task<Section?> FindBySection(string section)
Parameters
Returns
GetAll()
Retrieves all Section documents from the underlying collection by querying with an empty filter.
public Task<List<Section>> GetAll()
Returns
- Task<List<Section>>
A task that represents the asynchronous operation, containing a list of all Section documents found in the collection.
GetCollectionName()
Gets the configuration sections collection name from the API settings, falling back to a default value when not configured.
public override string GetCollectionName()
Returns
- string
The configured collection name, or "config_sections" if
_apiSettings.ConfigSectionsis null.
InsertOneSection(Section)
Asynchronously inserts a single Section into the collection and returns the persisted entity retrieved by its identifier.
If the insertion fails, the error is logged and the method returns null instead of propagating the exception.
public Task<Section?> InsertOneSection(Section section)
Parameters
sectionSectionThe section to insert into the collection.
Returns
UpdateSection(Section)
Updates an existing Section in the data store and returns the updated document. If no section with the specified identifier is found, the method returns null.
public Task<Section?> UpdateSection(Section section)
Parameters
sectionSectionThe section containing the identifier of the record to update and the new field values to persist.