diff --git a/adas-core.Infrastructure/Repositories/MasterListRepository.cs b/adas-core.Infrastructure/Repositories/MasterListRepository.cs
index a16f76be..9b4745ef 100644
--- a/adas-core.Infrastructure/Repositories/MasterListRepository.cs
+++ b/adas-core.Infrastructure/Repositories/MasterListRepository.cs
@@ -20,6 +20,7 @@ namespace adas_core.Infrastructure.Repositories;
/// options lists, diagnoses, allergies, procedures, treatments, and other reference data.
///
/// The type of MasterList entity to manage.
+///
public class MasterListRepository : MongoRepository, IMasterListRepository where T : MasterList
{
private readonly ApiSettings _apiSettings;
@@ -30,6 +31,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// API settings containing collection names configuration.
/// The MongoDB database instance.
/// Thrown when apiSettings is null.
+ ///
public MasterListRepository(IOptions apiSettings, IMongoDatabase database) : base(database)
{
if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings));
@@ -41,6 +43,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// Maps different MasterList subtypes to their corresponding MongoDB collection names.
///
/// The collection name for the current MasterList type.
+ ///
public override string GetCollectionName()
{
return typeof(T) switch
@@ -94,6 +97,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// The ObjectId of the entity to delete.
/// Throws and re-throws exceptions after logging.
+ ///
public async Task Delete(ObjectId id)
{
try
@@ -113,6 +117,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// The entity with updated values.
/// Throws and re-throws exceptions after logging.
+ ///
public async Task Update(T entity)
{
try
@@ -133,6 +139,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The ObjectId of the master list.
/// The OptionList with updated values.
/// The updated OptionList if found; otherwise, null.
+ ///
public async Task UpdateFullMasterListOption(ObjectId id, OptionList newOpt)
{
var filter = Builders.Filter.Where(o => o.Id == id && o.Options.Any(opt => opt.Id == newOpt.Id)
@@ -166,6 +173,12 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The ObjectId of the entity to retrieve.
/// The MasterList entity if found; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
+ ///
+ ///
public async Task FindById(ObjectId id)
{
try
@@ -197,6 +210,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The locale for translation.
/// The OptionList with translated fields if found; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
public async Task FindOptionItemById(ObjectId masterId, ObjectId optionId, LocaleEnum locale)
{
try
@@ -342,6 +357,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The ObjectId of the option to retrieve.
/// The OptionList if found; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
public async Task FindOptionItemById(ObjectId masterId, ObjectId optionId)
{
try
@@ -374,6 +390,10 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// Optional locale for translated option names.
/// The MasterList entity with translated options if found; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
+ ///
public async Task FindById(ObjectId id, LocaleEnum? locale)
{
try
@@ -556,6 +576,12 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The name of the master list to retrieve.
/// The MasterList entity if found; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
+ ///
+ ///
public async Task FindByName(string name)
{
try
@@ -584,6 +610,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The ObjectId of the master list.
/// Optional text to search within options.
/// A list of matching OptionList items.
+ ///
public async Task> GetMasterListByIdAndTextSearchContaining(ObjectId id, string? textSearch)
{
return await GetOptionsByTextSearch(textSearch, id);
@@ -594,6 +621,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// The pagination and filtering parameters.
/// A fluent queryable for MasterList results.
+ ///
public IFindFluent GetPaginatedMasterList(PaginationFilter filter)
{
var filterBuilder = Builders.Filter;
@@ -621,6 +649,10 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The pagination and filtering parameters.
/// The ObjectId of the master list.
/// A list of filtered OptionList items.
+ ///
+ ///
public async Task> GetPaginatedOptions(PaginationFilter filter, ObjectId listId)
{
//TODO: LOCALE
@@ -646,6 +678,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The option element to add.
/// The newly created OptionList if successful; otherwise, null if duplicate exists.
/// Logs errors and returns null on failure.
+ ///
public async Task AddOptionToMasterList(ObjectId id, FilterOptionListElement opt)
{
var exist = await GetMasterListByIdAndSearchOptions(id, opt);
@@ -689,6 +723,12 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// An enumerable of all MasterList entities.
/// Logs errors and returns empty list on failure.
+ ///
+ ///
+ ///
public async Task> GetAll()
{
try
@@ -708,6 +748,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// An enumerable of MasterListDto containing id, name, description, listType, and options count.
/// Logs errors and returns empty list on failure.
+ ///
public async Task> GetAllWithoutOptions()
{
try
@@ -736,6 +778,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// The total count of entities.
/// Logs errors and returns 0 on failure.
+ ///
public async Task Count()
{
try
@@ -758,6 +802,10 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The filter criteria including text, name, description, and optionType.
/// A list of matching OptionList items ordered by name.
/// Logs errors and returns empty list on failure.
+ ///
+ ///
public async Task> GetMasterListByIdAndSearchOptions(ObjectId id, FilterOptionListElement? filters)
{
try
@@ -973,6 +1021,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The locale for translation updates.
/// The updated OptionList if successful; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
public async Task UpdateMasterListOption(ObjectId id, OptionList newOpt, LocaleEnum locale)
{
// 1. Evitar duplicados
@@ -1073,6 +1123,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The OptionList with updated values.
/// The updated OptionList if successful; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
public async Task UpdateMasterListOption(ObjectId id, OptionList newOpt)
{
var master = await FindById(id);
@@ -1108,6 +1160,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The ObjectId of the master list.
/// The ObjectId of the option to delete.
/// True if the option was deleted; otherwise, false.
+ ///
public async Task DeleteMasterListOption(ObjectId id, ObjectId deleteOptId)
{
// Define el filtro para encontrar el documento por su _id
@@ -1132,6 +1185,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The UpdateMasterListDetailsDto with updated values.
/// The updated UpdateMasterListDetailsDto if successful; otherwise, null.
/// Logs errors and returns null on failure.
+ ///
public async Task UpdateOptionDetailsToMasterList(ObjectId id,
UpdateMasterListDetailsDto opt)
{
@@ -1167,6 +1222,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The new name.
/// True if the update was successful; otherwise, false.
/// Logs errors and returns false on failure.
+ ///
public async Task UpdateMasterListName(ObjectId id, string name)
{
var filter = Builders.Filter.And(
@@ -1193,6 +1250,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The new description.
/// True if the update was successful; otherwise, false.
/// Logs errors and returns false on failure.
+ ///
public async Task UpdateMasterListDescription(ObjectId id, string description)
{
var filter = Builders.Filter.And(
@@ -1219,6 +1278,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The OptionList to remove.
/// True if the option was removed; otherwise, false.
/// Logs errors and returns false on failure.
+ ///
public async Task RemoveMasterListOption(ObjectId id, OptionList oldOpt)
{
var filter = Builders.Filter.Eq("_id", id);
@@ -1250,6 +1310,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// Creates necessary indexes for the MasterList collection.
/// Currently creates text indexes for DiagnosisList on options.name, options.description, and options._id.
///
+ ///
public override async Task CreateIndexes()
{
if (typeof(T) == typeof(DiagnosisList))
@@ -1275,6 +1337,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// Optional text to search within options.
/// A list of matching OptionList items.
+ ///
public async Task> GetMasterListByTextSearch(string? textSearch)
{
return await GetOptionsByTextSearch(textSearch);
@@ -1287,6 +1350,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// Optional master list ObjectId to filter results.
/// A list of matching OptionList items ordered by name.
/// Logs errors and returns empty list on failure.
+ ///
private async Task> GetOptionsByTextSearch(string? textSearch, ObjectId? id = null)
{
try
@@ -1364,6 +1428,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// List of filter definitions to apply.
/// Sort definition for the query results.
/// A fluent queryable for T results.
+ ///
private IFindFluent CreateFindFluent(List> filters, SortDefinition sort)
{
var combinedFilter = filters.Any()
@@ -1379,6 +1445,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The default locale to exclude from translations.
/// The option name to use as default translation.
/// A Locale object with translations for all other locales.
+ ///
private Locale GetNewItemLocale(LocaleEnum localeList, string opt)
{
var newLocale = new Locale();
@@ -1418,6 +1485,7 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
///
/// The input string to build the pattern from.
/// A regex-compatible pattern string.
+ ///
private static string BuildRegexPattern(string input)
{
var regexPattern = new StringBuilder();
@@ -1459,6 +1527,8 @@ public class MasterListRepository : MongoRepository, IMasterListRepository
/// The locale for translation.
/// A list of matching OptionList items ordered by name.
/// Logs errors and returns empty list on failure.
+ ///
private async Task> GetMasterListByIdAndTextSearch(
ObjectId id, string newOptName, LocaleEnum locale)
{
diff --git a/adas-core.LdapLogin/LdapLoginService.cs b/adas-core.LdapLogin/LdapLoginService.cs
index c4f63619..b35d2b3c 100644
--- a/adas-core.LdapLogin/LdapLoginService.cs
+++ b/adas-core.LdapLogin/LdapLoginService.cs
@@ -20,6 +20,7 @@ namespace adas_core.LdapLogin;
/// The service also handles the creation of new users in the application if they do not already exist, based on the LDAP information.
/// It uses configuration settings for connecting to the LDAP server and for mapping LDAP attributes to user properties and authorities.
///
+///
public class LdapLoginService : ILoginService
{
///
@@ -51,6 +52,7 @@ public class LdapLoginService : ILoginService
/// The user service for managing user information.
/// The authority service for managing user authorities.
/// The logger for logging LDAP login operations.
+ ///
public LdapLoginService(
IOptions ldapConfig,
IValidator validator,
@@ -83,6 +85,7 @@ public class LdapLoginService : ILoginService
/// The authenticated user.
/// Thrown when there is an error during the login process.
/// Thrown when the user is not found in the LDAP directory.
+ ///
public async Task Login(string username, string password)
{
if (_ldapConfig.Server == null)
@@ -159,6 +162,7 @@ public class LdapLoginService : ILoginService
/// The HTTP context of the request.
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task Login(HttpContext context)
=> throw new LoginServicesException("Not implemented");
@@ -169,6 +173,7 @@ public class LdapLoginService : ILoginService
/// The password of the user to authenticate.
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task Authenticate(string username, string password)
=> throw new LoginServicesException("Not implemented");
@@ -178,6 +183,7 @@ public class LdapLoginService : ILoginService
/// The ID of the user to retrieve.
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task GetById(ObjectId id)
=> throw new LoginServicesException("Not implemented");
@@ -187,6 +193,7 @@ public class LdapLoginService : ILoginService
/// The email of the user to retrieve.
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task GetByEmail(string email)
=> throw new LoginServicesException("Not implemented");
@@ -196,6 +203,8 @@ public class LdapLoginService : ILoginService
/// The username of the user to retrieve.
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task GetByUsername(string username)
=> throw new LoginServicesException("Not implemented");
@@ -204,6 +213,8 @@ public class LdapLoginService : ILoginService
///
/// A task representing the asynchronous operation.
/// Thrown when the method is not implemented.
+ ///
public Task> GetAllUsers()
=> throw new LoginServicesException("Not implemented");
@@ -215,6 +226,7 @@ public class LdapLoginService : ILoginService
/// The user information obtained from the LDAP entry.
/// The LDAP entry containing the user's information.
/// The existing or newly created user with updated authorities.
+ ///
private async Task GetOrCreateUser(User userEntryLdap, LdapEntry entry)
{
@@ -239,6 +251,7 @@ public class LdapLoginService : ILoginService
/// The user whose authorities are being checked.
/// The LDAP entry containing the user's information.
/// A list of updated authorities for the user.
+ ///
private async Task> CheckAuthorities(User user, LdapEntry entry)
{
@@ -289,6 +302,7 @@ public class LdapLoginService : ILoginService
/// The LDAP entry containing the user's information.
/// The user whose authorities are being retrieved.
/// A list of authorities for the user based on the whitelist.
+ ///
private List GetAuthoritiesWhiteList(LdapEntry entry, User user)
{
@@ -331,6 +345,10 @@ public class LdapLoginService : ILoginService
///
/// The LDAP entry containing the user's information.
/// The existing or newly created user with updated authorities.
+ ///
+ ///
private User GetUser(LdapEntry ldapEntry)
{
@@ -365,6 +383,7 @@ public class LdapLoginService : ILoginService
/// The LDAP entry containing the user's information.
/// The user whose authorities are being retrieved.
/// A list of authorities for the user based on the LDAP entry and the application's configuration.
+ ///
private List GetAuthoritiesMap(LdapEntry ldapEntry, User user)
{