=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -13,6 +13,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// Repository implementation for managing <see cref="Medicine"/> entities in MongoDB.
|
||||
/// Provides CRUD operations, search, pagination, and aggregation capabilities specific to medicines.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=16673ad -->
|
||||
public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
@@ -23,6 +24,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// <param name="apiSettings">The application API settings containing configuration values, including the collection name. Cannot be <see langword="null"/>.</param>
|
||||
/// <param name="database">The MongoDB database instance used to access the collection.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="apiSettings"/> is <see langword="null"/>.</exception>
|
||||
/// <!-- aidoc:v1 sig=78d0590 body=d2b18a3 -->
|
||||
public MedicineRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database) : base(database)
|
||||
{
|
||||
if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings));
|
||||
@@ -36,6 +38,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// Falls back to the default "medicines" collection name when not configured in the API settings.
|
||||
/// </summary>
|
||||
/// <returns>The collection name retrieved from the API settings, or "medicines" if not configured.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=24e9d1c -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.Medicines ?? "medicines";
|
||||
@@ -49,6 +52,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{Medicine}"/> representing the asynchronous operation.
|
||||
/// The task result contains the first <see cref="Medicine"/> matching the criteria, or <see langword="null"/> if no match is found.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=b6d43c1 body=db3587a -->
|
||||
public async Task<Medicine?> GetMedicine(string code)
|
||||
{
|
||||
var result = await Collection.FindAsync(x => x.Codes.Contains(code) || x.Notes.Contains(code));
|
||||
@@ -65,6 +69,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{List{Medicine}}"/> representing the asynchronous operation.
|
||||
/// The task result contains a list of matching <see cref="Medicine"/> objects. Returns an empty list if no matches are found.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=68faf9f body=85d920f -->
|
||||
public async Task<List<Medicine>> GetMedicineByCodeOrNote(List<string> codeNotes)
|
||||
{
|
||||
var filter = Builders<Medicine>.Filter.AnyIn("Codes", codeNotes.ToArray());
|
||||
@@ -81,6 +86,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{Medicine}"/> representing the asynchronous operation.
|
||||
/// The task result contains the <see cref="Medicine"/> if found; otherwise, <see langword="null"/>.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=84930f7 body=2ce8f8c -->
|
||||
public async Task<Medicine?> GetMedicineByName(string name)
|
||||
{
|
||||
var filter = Builders<Medicine>.Filter.Eq(p => p.Name, name);
|
||||
@@ -96,6 +102,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{List{Medicine}}"/> representing the asynchronous operation.
|
||||
/// The task result contains a list of all <see cref="Medicine"/> objects. Returns an empty list if the collection is empty.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=6bce187 body=bdbdf96 -->
|
||||
public async Task<List<Medicine>> GetAll()
|
||||
{
|
||||
var result = await Collection.FindAsync(_ => true);
|
||||
@@ -111,6 +118,8 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{Medicine}"/> representing the asynchronous operation.
|
||||
/// The task result contains the <see cref="Medicine"/> if found; otherwise, <see langword="null"/>.
|
||||
/// </returns>
|
||||
/// <!-- aidoc-review:v1 severity=low kind=wrong_returns
|
||||
/// "The cref uses Task{Medicine} but the method's actual return type is Task<Medicine?>; however, the explanatory sentence correctly describes the nullable behavior." -->
|
||||
public async Task<Medicine?> GetMedicineById(ObjectId medicineId)
|
||||
{
|
||||
var filter = Builders<Medicine>.Filter.Eq(p => p.Id, medicineId);
|
||||
@@ -127,6 +136,8 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{Medicine}"/> representing the asynchronous operation.
|
||||
/// The task result contains the newly inserted <see cref="Medicine"/> retrieved by its name, or <see langword="null"/> if the lookup fails.
|
||||
/// </returns>
|
||||
/// <!-- aidoc-review:v1 severity=low kind=wrong_returns
|
||||
/// "The return type is Task<Medicine?> (nullable), but the cref uses Task{Medicine} which represents the non-nullable Task<Medicine>. The prose does mention null, so meaning is preserved." -->
|
||||
public async Task<Medicine?> PostMedicine(Medicine medicine)
|
||||
{
|
||||
await Collection.InsertOneAsync(medicine);
|
||||
@@ -143,6 +154,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// A <see cref="Task{Medicine}"/> representing the asynchronous operation.
|
||||
/// The task result contains the same <see cref="Medicine"/> instance that was passed in, after the update operation has been issued.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=baa8582 body=be3411f -->
|
||||
public async Task<Medicine?> UpdateMedicine(Medicine medicine)
|
||||
{
|
||||
await UpdateOneAsync(medicine.Id, medicine);
|
||||
@@ -155,6 +167,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// </summary>
|
||||
/// <param name="medicineId">The <see cref="ObjectId"/> of the medicine to delete.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous delete operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=ea3ac00 body=5d15af8 -->
|
||||
public async Task DeleteMedicineById(ObjectId medicineId)
|
||||
{
|
||||
var filter = Builders<Medicine>.Filter.Eq(po => po.Id, medicineId);
|
||||
@@ -172,6 +185,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// An <see cref="IFindFluent{Medicine, Medicine}"/> instance that can be used to further refine and execute the query.
|
||||
/// When no filters are provided, all medicines are returned sorted by name.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=067ab87 body=1dc1cf3 -->
|
||||
public IFindFluent<Medicine, Medicine> GetPaginatedMedicines(PaginationFilter filter)
|
||||
{
|
||||
// Crear variable con la clase que construye los filtros que necesitamos
|
||||
@@ -220,6 +234,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// An <see cref="IAggregateFluent{BsonDocument}"/> representing the aggregation pipeline that, when executed,
|
||||
/// yields documents containing the distinct values of the specified field.
|
||||
/// </returns>
|
||||
/// <!-- aidoc:v1 sig=3fad0c3 body=ba53337 -->
|
||||
public IAggregateFluent<BsonDocument> GetDistinctFieldDataQuery(string field)
|
||||
{
|
||||
return Collection.Aggregate()
|
||||
@@ -238,6 +253,7 @@ public class MedicineRepository : MongoRepository<Medicine>, IMedicineRepository
|
||||
/// containing a list of distinct group names as strings.
|
||||
/// </returns>
|
||||
/// <exception cref="NotImplementedException">This method is not yet implemented.</exception>
|
||||
/// <!-- aidoc:v1 sig=4759c2c body=bfa6f2f -->
|
||||
public Task<List<string>> GetAllGroups()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user