Class LightBeaconRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Repository implementation for managing LightBeacon entities in MongoDB. Provides CRUD operations and query capabilities specific to light beacons.
public class LightBeaconRepository : MongoRepository<LightBeacon>, ILightBeaconRepository, IMongoRepository<LightBeacon>
- Inheritance
-
LightBeaconRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
LightBeaconRepository(IMongoDatabase, IOptions<ApiSettings>)
Initializes a new instance of the LightBeaconRepository class.
public LightBeaconRepository(IMongoDatabase database, IOptions<ApiSettings> apiSettings)
Parameters
databaseIMongoDatabaseThe MongoDB database instance used to access the collection.
apiSettingsIOptions<ApiSettings>The application API settings containing configuration values, including the collection name.
Methods
GetById(ObjectId)
Asynchronously retrieves a light beacon by its unique identifier.
public Task<LightBeacon?> GetById(ObjectId relayId)
Parameters
relayIdObjectIdThe MongoDB.Bson.ObjectId of the relay (light beacon) to retrieve.
Returns
- Task<LightBeacon>
A Task<TResult> representing the asynchronous operation. The task result contains the LightBeacon if found; otherwise, null.
GetByName(string?)
Asynchronously retrieves a light beacon by its name.
public Task<LightBeacon?> GetByName(string? requestRelayName)
Parameters
Returns
- Task<LightBeacon>
A Task<TResult> representing the asynchronous operation. The task result contains the LightBeacon if found; otherwise, null.
GetCollectionName()
Gets the name of the MongoDB collection used to store light beacons.
public override string GetCollectionName()
Returns
- string
The collection name retrieved from the API settings.
GetLightBeaconInList(List<ObjectId>)
Retrieves a list of light beacons whose identifiers are contained in the provided list of configuration relay identifiers.
public List<LightBeacon> GetLightBeaconInList(List<ObjectId> configurationRelayList)
Parameters
configurationRelayListList<ObjectId>A list of MongoDB.Bson.ObjectId values representing the relay identifiers to filter by.
Returns
- List<LightBeacon>
A List<T> containing the matching light beacons. Returns an empty list if no matches are found.
GetPaginatedRelays(PaginationFilter)
Retrieves a paginated, sorted, and filtered set of light beacons based on the provided pagination filter. Results are sorted ascending by name. When a text filter is provided, a case-insensitive regex match is performed on the name field.
public IFindFluent<LightBeacon, LightBeacon> GetPaginatedRelays(PaginationFilter filter)
Parameters
filterPaginationFilterThe PaginationFilter containing pagination and filtering criteria.
Returns
- IFindFluent<LightBeacon, LightBeacon>
An MongoDB.Driver.IFindFluent<TDocument, TProjection> instance that can be used to further refine and execute the query.
Exceptions
- BadRequestException
Thrown when the text filter exceeds 100 characters in length.
GetSearchByName(string)
Searches for light beacons whose name matches the specified text.
public Task<List<LightBeacon>> GetSearchByName(string textToSearch)
Parameters
textToSearchstringThe text to search for within light beacon names.
Returns
- Task<List<LightBeacon>>
A Task<TResult> representing the asynchronous operation, containing a list of matching LightBeacon objects.
Exceptions
- NotImplementedException
This method is not yet implemented.
InsertOneAsyncAndReturn(LightBeacon)
Asynchronously inserts a new light beacon into the database and returns the inserted entity.
public Task<LightBeacon?> InsertOneAsyncAndReturn(LightBeacon beacon)
Parameters
beaconLightBeaconThe LightBeacon instance to insert.
Returns
- Task<LightBeacon>
A Task<TResult> representing the asynchronous operation. The task result contains the inserted LightBeacon if successful; otherwise, null if the operation fails.