=== 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:
@@ -16,6 +16,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// <summary>
|
||||
/// Represents a MongoDB-backed repository for <see cref="Unit"/> entities, inheriting persistence functionality from <see cref="MongoRepository{Unit}"/> and implementing the <see cref="IUnitRepository"/> contract.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=2997ff1 -->
|
||||
public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
{
|
||||
#region Properties
|
||||
@@ -51,6 +52,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="unit">The <see cref="Unit"/> to be inserted into the collection.</param>
|
||||
/// <returns>The inserted <see cref="Unit"/> as returned by the lookup by identifier, or <c>null</c> if an exception occurred during insertion.</returns>
|
||||
/// <!-- aidoc:v1 sig=46b66ca body=55b385e -->
|
||||
public async Task<Unit?> InsertOneUnit(Unit unit)
|
||||
{
|
||||
try
|
||||
@@ -75,6 +77,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// Gets the collection name for units, returning the configured value from API settings or falling back to the default "units" when not specified.
|
||||
/// </summary>
|
||||
/// <returns>The collection name for units, or "units" if no custom value is configured in the API settings.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=48f375a -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.Units ?? "units";
|
||||
@@ -94,6 +97,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the <see cref="Unit"/> to locate.</param>
|
||||
/// <returns>A <see cref="Unit"/> instance if a match is found; otherwise, <see langword="null"/>.</returns>
|
||||
/// <!-- aidoc:v1 sig=2cb132e body=4a4ce42 -->
|
||||
public async Task<Unit?> FindById(object id)
|
||||
{
|
||||
var result = await Collection.FindAsync(Builders<Unit>.Filter.Eq(x => x.Id, id));
|
||||
@@ -106,6 +110,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// <param name="id">The unique identifier of the unit to look up.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the matching <see cref="Unit"/>, or <c>null</c> if no unit is found with the specified identifier.</returns>
|
||||
/// <exception cref="NotImplementedException">The method is not yet implemented.</exception>
|
||||
/// <!-- aidoc:v1 sig=b1966a7 body=bfa6f2f -->
|
||||
public Task<Unit?> FindById(string id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -144,6 +149,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="ObjectId"/> of the master list to search for across the unit's list reference fields.</param>
|
||||
/// <returns>A task that yields an <see cref="IEnumerable{Unit}"/> containing the matching units, or an empty list if no matches are found or an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=be856f1 body=b563580 -->
|
||||
public async Task<IEnumerable<Unit>> FindByMasterListId(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -196,6 +202,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// <param name="id">The <see cref="ObjectId"/> of the master list used to match units.</param>
|
||||
/// <param name="masterListType">The type of master list, which determines the property name used in the filter.</param>
|
||||
/// <returns>The total number of <see cref="Unit"/> documents that match the filter.</returns>
|
||||
/// <!-- aidoc:v1 sig=22d5ac5 body=8e9b4d7 -->
|
||||
public async Task<long> CountUnitsByMasterListId(ObjectId id, MasterListType masterListType)
|
||||
{
|
||||
var propertyName = $"{masterListType}Id";
|
||||
@@ -209,6 +216,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="unitName">The name of the unit to look up using an exact equality match.</param>
|
||||
/// <returns>A <see cref="Task{Unit?}"/> containing the matching <see cref="Unit"/> if found; otherwise, <c>null</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=12e24aa body=ec93cdf -->
|
||||
public async Task<Unit?> FindByName(string unitName)
|
||||
{
|
||||
var result = await Collection.FindAsync(Builders<Unit>.Filter.Eq(x => x.Name, unitName));
|
||||
@@ -241,6 +249,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// Asynchronously retrieves all <see cref="Unit"/> records from the underlying collection.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of all <see cref="Unit"/> documents found in the collection.</returns>
|
||||
/// <!-- aidoc:v1 sig=b1cb9b5 body=bc87eac -->
|
||||
public async Task<List<Unit>> GetAll()
|
||||
{
|
||||
var result = await Collection.FindAsync(Builders<Unit>.Filter.Empty);
|
||||
@@ -254,6 +263,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="filter">The pagination filter containing the optional text search criteria used to narrow the result set.</param>
|
||||
/// <returns>An <see cref="IFindFluent{Unit, Unit}"/> representing the sorted and filtered query of units; if no filter request is supplied, an unfiltered query sorted by title is returned.</returns>
|
||||
/// <!-- aidoc:v1 sig=9b2e0d7 body=ec22e2e -->
|
||||
public IFindFluent<Unit, Unit> GetPaginatedUnits(PaginationFilter filter)
|
||||
{
|
||||
var filterBuilder = Builders<Unit>.Filter;
|
||||
@@ -286,6 +296,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// <param name="filters">The list of filter definitions to combine with a logical AND; if empty, no filtering is applied.</param>
|
||||
/// <param name="sort">The sort definition to apply to the query results.</param>
|
||||
/// <returns>A fluent find interface for <see cref="Unit"/> that can be further chained to project, limit, or execute the query.</returns>
|
||||
/// <!-- aidoc:v1 sig=ef193db body=8638b4d -->
|
||||
private IFindFluent<Unit, Unit> CreateFindFluent(List<FilterDefinition<Unit>> filters, SortDefinition<Unit> sort)
|
||||
{
|
||||
var combinedFilter = filters.Any()
|
||||
@@ -304,6 +315,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="unit">The unit containing the identifier and the new field values to be persisted.</param>
|
||||
/// <returns>The updated unit after the operation, or null if no document matched the filter.</returns>
|
||||
/// <!-- aidoc:v1 sig=2e95c1d body=72db12f -->
|
||||
public async Task<Unit?> UpdateUnit(Unit unit)
|
||||
{
|
||||
var filter = Builders<Unit>.Filter.Eq("_id", unit.Id);
|
||||
@@ -343,6 +355,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// <param name="name">The new name to assign to the unit.</param>
|
||||
/// <param name="title">The new title to assign to the unit.</param>
|
||||
/// <returns>The updated <see cref="Unit"/> after the modification, or <c>null</c> if no matching unit was found.</returns>
|
||||
/// <!-- aidoc:v1 sig=cb1f7cc body=764f8fb -->
|
||||
public async Task<Unit?> UpdateUnitInfo(ObjectId unitId, string name, string title)
|
||||
{
|
||||
var filter = Builders<Unit>.Filter.Eq("_id", unitId);
|
||||
@@ -364,6 +377,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="updateUnitListDto">The DTO containing the target <c>UnitId</c> and the collection of master list entries to update.</param>
|
||||
/// <returns>The updated <see cref="Unit"/> after the modifications, or <c>null</c> if no updates were performed.</returns>
|
||||
/// <!-- aidoc:v1 sig=303c1f2 body=9b5590e -->
|
||||
public async Task<Unit?> UpdateUnitMasterList(UpdateUnitIdListDto updateUnitListDto)
|
||||
{
|
||||
var filter = Builders<Unit>.Filter.Eq("_id", updateUnitListDto.UnitId);
|
||||
@@ -459,6 +473,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// <param name="unitIdParsed">The <see cref="ObjectId"/> of the unit whose configuration will be updated.</param>
|
||||
/// <param name="unitConfiguration">The new <see cref="UnitConfiguration"/> to apply to the unit.</param>
|
||||
/// <returns>A task that resolves to <c>true</c> when the update modified a document; otherwise <c>false</c> (including when the operation throws and the error is logged).</returns>
|
||||
/// <!-- aidoc:v1 sig=0ae31e8 body=dd19aa3 -->
|
||||
public async Task<bool> UpdateConfiguration(ObjectId unitIdParsed, UnitConfiguration unitConfiguration)
|
||||
{
|
||||
var filter = Builders<Unit>.Filter.Eq("_id", unitIdParsed);
|
||||
@@ -485,6 +500,7 @@ public class UnitRepository : MongoRepository<Unit>, IUnitRepository
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the unit to delete.</param>
|
||||
/// <returns>The deleted <see cref="Unit"/> if found and removed; otherwise, <c>null</c> when an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=07e45cd body=5ae0f5c -->
|
||||
public new async Task<Unit?> DeleteAsync(ObjectId id)
|
||||
{
|
||||
var filter = Builders<Unit>.Filter.Eq(unit => unit.Id, id);
|
||||
|
||||
Reference in New Issue
Block a user