Uncomment the cache settings
This commit is contained in:
		| @@ -138,7 +138,7 @@ namespace LSA.Core.Thalos.API.Controllers | |||||||
|         //[Permission("ModuleManagement.Write")] |         //[Permission("ModuleManagement.Write")] | ||||||
|         public async Task<IActionResult> UpdateModuleAsync([FromRoute] string id, ModuleAdapter entity, CancellationToken cancellationToken) |         public async Task<IActionResult> UpdateModuleAsync([FromRoute] string id, ModuleAdapter entity, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (id != entity._Id?.ToString()) |             if (id != entity.Id?.ToString()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("Module ID mismatch"); |                 return BadRequest("Module ID mismatch"); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -136,7 +136,7 @@ namespace LSA.Core.Thalos.API.Controllers | |||||||
|         //[Permission("PermissionManagement.Write")] |         //[Permission("PermissionManagement.Write")] | ||||||
|         public async Task<IActionResult> UpdatePermissionAsync([FromRoute] string id, PermissionAdapter entity, CancellationToken cancellationToken) |         public async Task<IActionResult> UpdatePermissionAsync([FromRoute] string id, PermissionAdapter entity, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (id != entity._Id?.ToString()) |             if (id != entity.Id?.ToString()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("Permission ID mismatch"); |                 return BadRequest("Permission ID mismatch"); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -103,7 +103,7 @@ namespace LSA.Core.Thalos.API.Controllers | |||||||
|         //[Permission("RoleManagement.Write")] |         //[Permission("RoleManagement.Write")] | ||||||
|         public async Task<IActionResult> UpdateRoleAsync([FromRoute] string id, [FromBody] RoleAdapter entity, CancellationToken cancellationToken) |         public async Task<IActionResult> UpdateRoleAsync([FromRoute] string id, [FromBody] RoleAdapter entity, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (id != entity._Id?.ToString()) |             if (id != entity.Id?.ToString()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("Role ID mismatch"); |                 return BadRequest("Role ID mismatch"); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -152,7 +152,7 @@ namespace LSA.Core.Thalos.API.Controllers | |||||||
|         //[Permission("UserManagement.Write")] |         //[Permission("UserManagement.Write")] | ||||||
|         public async Task<IActionResult> UpdateUserAsync([FromRoute] string id, [FromBody] UserAdapter entity, CancellationToken cancellationToken) |         public async Task<IActionResult> UpdateUserAsync([FromRoute] string id, [FromBody] UserAdapter entity, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             if (id != entity._Id?.ToString()) |             if (id != entity.Id?.ToString()) | ||||||
|             { |             { | ||||||
|                 return BadRequest("User ID mismatch"); |                 return BadRequest("User ID mismatch"); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -49,7 +49,7 @@ namespace Core.Thalos.Provider.Contracts | |||||||
|         /// <param name="eamil">The User email.</param> |         /// <param name="eamil">The User email.</param> | ||||||
|         /// <returns>A <see cref="{Task{UserAdapter}}"/> representing |         /// <returns>A <see cref="{Task{UserAdapter}}"/> representing | ||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         ValueTask<UserAdapter> ValidateUserExistence(string? email, CancellationToken cancellationToken); |         ValueTask<UserExistenceAdapter> ValidateUserExistence(string? email, CancellationToken cancellationToken); | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Changes the status of the user. |         /// Changes the status of the user. | ||||||
|   | |||||||
| @@ -5,7 +5,6 @@ | |||||||
| // *********************************************************************** | // *********************************************************************** | ||||||
| using Core.Thalos.Adapters; | using Core.Thalos.Adapters; | ||||||
| using Core.Blueprint.Mongo; | using Core.Blueprint.Mongo; | ||||||
| using Core.Blueprint.Caching; |  | ||||||
| using Core.Blueprint.Caching.Helpers; | using Core.Blueprint.Caching.Helpers; | ||||||
| using Mapster; | using Mapster; | ||||||
| using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||||
| @@ -107,9 +106,9 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|             var builder = Builders<ModuleAdapter>.Filter; |             var builder = Builders<ModuleAdapter>.Filter; | ||||||
|             var filters = new List<FilterDefinition<ModuleAdapter>>(); |             var filters = new List<FilterDefinition<ModuleAdapter>>(); | ||||||
|  |  | ||||||
|             if (modules == null || !modules.Any()) |             if (modules != null || !modules.Any()) | ||||||
|             { |             { | ||||||
|                 filters.Add(builder.In(x => x.Id, modules)); |                 filters.Add(builder.In(x => x._Id, modules)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             var finalFilter = filters.Any() ? builder.And(filters) : builder.Empty; |             var finalFilter = filters.Any() ? builder.And(filters) : builder.Empty; | ||||||
|   | |||||||
| @@ -3,15 +3,16 @@ | |||||||
| //     AgileWebs | //     AgileWebs | ||||||
| // </copyright> | // </copyright> | ||||||
| // *********************************************************************** | // *********************************************************************** | ||||||
| using Core.Thalos.Adapters; | using Core.Blueprint.Caching.Adapters; | ||||||
|  | using Core.Blueprint.Caching.Contracts; | ||||||
|  | using Core.Blueprint.Caching.Helpers; | ||||||
| using Core.Blueprint.Mongo; | using Core.Blueprint.Mongo; | ||||||
| //using Core.Blueprint.Redis; | using Core.Thalos.Adapters; | ||||||
| //using Core.Blueprint.Redis.Helpers; | using Core.Thalos.Domain.Contexts.Onboarding.Request; | ||||||
|  | using Core.Thalos.Provider.Contracts; | ||||||
| using Mapster; | using Mapster; | ||||||
| using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||||
| using MongoDB.Driver; | using MongoDB.Driver; | ||||||
| using Core.Thalos.Provider.Contracts; |  | ||||||
| using Core.Thalos.Domain.Contexts.Onboarding.Request; |  | ||||||
|  |  | ||||||
| namespace Core.Thalos.Provider.Providers.Onboarding | namespace Core.Thalos.Provider.Providers.Onboarding | ||||||
| { | { | ||||||
| @@ -21,18 +22,18 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|     public class PermissionProvider : IPermissionProvider |     public class PermissionProvider : IPermissionProvider | ||||||
|     { |     { | ||||||
|         private readonly CollectionRepository<PermissionAdapter> repository; |         private readonly CollectionRepository<PermissionAdapter> repository; | ||||||
|         //private readonly CacheSettings cacheSettings; |         private readonly CacheSettings cacheSettings; | ||||||
|         //private readonly IRedisCacheProvider cacheProvider; |         private readonly ICacheProvider cacheProvider; | ||||||
|  |  | ||||||
|         public PermissionProvider(CollectionRepository<PermissionAdapter> repository |         public PermissionProvider(CollectionRepository<PermissionAdapter> repository, | ||||||
|         //IRedisCacheProvider cacheProvider,  |             ICacheProvider cacheProvider, | ||||||
|         //IOptions<CacheSettings> cacheSettings |             IOptions<CacheSettings> cacheSettings | ||||||
|             ) |             ) | ||||||
|         { |         { | ||||||
|             this.repository = repository; |             this.repository = repository; | ||||||
|             this.repository.CollectionInitialization(); |             this.repository.CollectionInitialization(); | ||||||
|             //this.cacheSettings = cacheSettings.Value; |             this.cacheSettings = cacheSettings.Value; | ||||||
|             //this.cacheProvider = cacheProvider; |             this.cacheProvider = cacheProvider; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
| @@ -58,14 +59,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns>0 |         /// the asynchronous execution of the service.</returns>0 | ||||||
|         public async ValueTask<PermissionAdapter> GetPermissionById(string _id, CancellationToken cancellationToken) |         public async ValueTask<PermissionAdapter> GetPermissionById(string _id, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetPermissionById", _id); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetPermissionById", _id); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<PermissionAdapter>(cacheKey); |             var cachedData = await cacheProvider.GetAsync<PermissionAdapter>(cacheKey); | ||||||
|  |  | ||||||
|             //if (cachedData is not null) { return cachedData; } |             //if (cachedData is not null) { return cachedData; } | ||||||
|  |  | ||||||
|             var permission = await repository.FindByIdAsync(_id); |             var permission = await repository.FindByIdAsync(_id); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, permission); |             await cacheProvider.SetAsync(cacheKey, permission); | ||||||
|  |  | ||||||
|             return permission; |             return permission; | ||||||
|         } |         } | ||||||
| @@ -77,14 +78,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<IEnumerable<PermissionAdapter>> GetAllPermissions(CancellationToken cancellationToken) |         public async ValueTask<IEnumerable<PermissionAdapter>> GetAllPermissions(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllPermissions"); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllPermissions"); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<PermissionAdapter>>(cacheKey) ?? []; |             var cachedData = await cacheProvider.GetAsync<IEnumerable<PermissionAdapter>>(cacheKey) ?? []; | ||||||
|  |  | ||||||
|             //if (cachedData.Any()) return cachedData; |             if (cachedData.Any()) return cachedData; | ||||||
|  |  | ||||||
|             var permissions = await repository.AsQueryable(); |             var permissions = await repository.AsQueryable(); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, permissions); |             await cacheProvider.SetAsync(cacheKey, permissions); | ||||||
|  |  | ||||||
|             return permissions; |             return permissions; | ||||||
|         } |         } | ||||||
| @@ -97,25 +98,25 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<IEnumerable<PermissionAdapter>> GetAllPermissionsByList(string[] permissions, CancellationToken cancellationToken) |         public async ValueTask<IEnumerable<PermissionAdapter>> GetAllPermissionsByList(string[] permissions, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllPermissionsByList", permissions); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllPermissionsByList", permissions); | ||||||
|  |  | ||||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<PermissionAdapter>>(cacheKey) ?? []; |             var cachedData = await cacheProvider.GetAsync<IEnumerable<PermissionAdapter>>(cacheKey) ?? []; | ||||||
|  |  | ||||||
|             //if (cachedData.Any()) return cachedData; |             if (cachedData.Any()) return cachedData; | ||||||
|  |  | ||||||
|             var builder = Builders<PermissionAdapter>.Filter; |             var builder = Builders<PermissionAdapter>.Filter; | ||||||
|             var filters = new List<FilterDefinition<PermissionAdapter>>(); |             var filters = new List<FilterDefinition<PermissionAdapter>>(); | ||||||
|  |  | ||||||
|             if (permissions == null || !permissions.Any()) |             if (permissions != null || !permissions.Any()) | ||||||
|             { |             { | ||||||
|                 filters.Add(builder.In(x => x.Id, permissions)); |                 filters.Add(builder.In(x => x._Id, permissions)); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             var finalFilter = filters.Any() ? builder.And(filters) : builder.Empty; |             var finalFilter = filters.Any() ? builder.And(filters) : builder.Empty; | ||||||
|  |  | ||||||
|             var permissionsList = await repository.FilterByMongoFilterAsync(finalFilter); |             var permissionsList = await repository.FilterByMongoFilterAsync(finalFilter); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, permissionsList); |             await cacheProvider.SetAsync(cacheKey, permissionsList); | ||||||
|  |  | ||||||
|             return permissionsList; |             return permissionsList; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -3,21 +3,22 @@ | |||||||
| //     AgileWebs | //     AgileWebs | ||||||
| // </copyright> | // </copyright> | ||||||
| // *********************************************************************** | // *********************************************************************** | ||||||
|  | using Core.Blueprint.Caching.Adapters; | ||||||
|  | using Core.Blueprint.Caching.Contracts; | ||||||
|  | using Core.Blueprint.Caching.Helpers; | ||||||
|  | using Core.Blueprint.Mongo; | ||||||
| using Core.Thalos.Adapters; | using Core.Thalos.Adapters; | ||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.Adapters.Common.Enums; | ||||||
| using Core.Blueprint.Mongo; | using Core.Thalos.Domain.Contexts.Onboarding.Request; | ||||||
| //using Core.Blueprint.Redis; | using Core.Thalos.Provider.Contracts; | ||||||
| //using Core.Blueprint.Redis.Helpers; |  | ||||||
| using Mapster; | using Mapster; | ||||||
| using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||||
| using MongoDB.Driver; |  | ||||||
| using Core.Thalos.Provider.Contracts; |  | ||||||
| using MongoDB.Bson; |  | ||||||
| using System.Text.RegularExpressions; |  | ||||||
| using MongoDB.Bson.Serialization; |  | ||||||
| using Core.Thalos.Domain.Contexts.Onboarding.Request; |  | ||||||
| using Microsoft.Graph; | using Microsoft.Graph; | ||||||
|  | using MongoDB.Bson; | ||||||
|  | using MongoDB.Bson.Serialization; | ||||||
|  | using MongoDB.Driver; | ||||||
| using System.ComponentModel.Design; | using System.ComponentModel.Design; | ||||||
|  | using System.Text.RegularExpressions; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Provider.Providers.Onboarding | namespace Core.Thalos.Provider.Providers.Onboarding | ||||||
| { | { | ||||||
| @@ -27,19 +28,19 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|     public class RoleProvider : IRoleProvider |     public class RoleProvider : IRoleProvider | ||||||
|     { |     { | ||||||
|         private readonly CollectionRepository<RoleAdapter> repository; |         private readonly CollectionRepository<RoleAdapter> repository; | ||||||
|         //private readonly CacheSettings cacheSettings; | 		private readonly CacheSettings cacheSettings; | ||||||
|         //private readonly IRedisCacheProvider cacheProvider; | 		private readonly ICacheProvider cacheProvider; | ||||||
|  |  | ||||||
|         public RoleProvider(CollectionRepository<RoleAdapter> repository | 		public RoleProvider(CollectionRepository<RoleAdapter> repository, | ||||||
|         //IRedisCacheProvider cacheProvider,  | 		    ICacheProvider cacheProvider, | ||||||
|         //IOptions<CacheSettings> cacheSettings | 			IOptions<CacheSettings> cacheSettings | ||||||
|             ) | 			) | ||||||
|         { |         { | ||||||
|             this.repository = repository; |             this.repository = repository; | ||||||
|             this.repository.CollectionInitialization(); |             this.repository.CollectionInitialization(); | ||||||
|             //this.cacheSettings = cacheSettings.Value; | 			this.cacheSettings = cacheSettings.Value; | ||||||
|             //this.cacheProvider = cacheProvider; | 			this.cacheProvider = cacheProvider; | ||||||
|         } | 		} | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Creates a new Role. |         /// Creates a new Role. | ||||||
| @@ -64,14 +65,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<RoleAdapter> GetRoleById(string _id, CancellationToken cancellationToken) |         public async ValueTask<RoleAdapter> GetRoleById(string _id, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<RoleAdapter>(cacheKey); |             var cachedData = await cacheProvider.GetAsync<RoleAdapter>(cacheKey); | ||||||
|  |  | ||||||
|             //if (cachedData is not null) { return cachedData; } |             if (cachedData is not null) { return cachedData; } | ||||||
|  |  | ||||||
|             var role = await repository.FindByIdAsync(_id); |             var role = await repository.FindByIdAsync(_id); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, role); |             await cacheProvider.SetAsync(cacheKey, role); | ||||||
|  |  | ||||||
|             return role; |             return role; | ||||||
|         } |         } | ||||||
| @@ -83,14 +84,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<IEnumerable<RoleAdapter>> GetAllRoles(CancellationToken cancellationToken) |         public async ValueTask<IEnumerable<RoleAdapter>> GetAllRoles(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; |             var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; | ||||||
|  |  | ||||||
|             //if (cachedData.Any()) return cachedData; |             if (cachedData.Any()) return cachedData; | ||||||
|  |  | ||||||
|             var roles = await repository.AsQueryable(); |             var roles = await repository.AsQueryable(); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, roles); |             await cacheProvider.SetAsync(cacheKey, roles); | ||||||
|  |  | ||||||
|             return roles; |             return roles; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -4,18 +4,20 @@ | |||||||
| // </copyright> | // </copyright> | ||||||
| // *********************************************************************** | // *********************************************************************** | ||||||
|  |  | ||||||
|  | using Core.Blueprint.Caching.Adapters; | ||||||
|  | using Core.Blueprint.Caching.Contracts; | ||||||
|  | using Core.Blueprint.Caching.Helpers; | ||||||
|  | using Core.Blueprint.Mongo; | ||||||
| using Core.Thalos.Adapters; | using Core.Thalos.Adapters; | ||||||
| using Core.Thalos.Adapters.Common.Enums; | using Core.Thalos.Adapters.Common.Enums; | ||||||
| using Core.Blueprint.Mongo; | using Core.Thalos.Provider.Contracts; | ||||||
| //using Core.Blueprint.Redis; |  | ||||||
| //using Core.Blueprint.Redis.Helpers; |  | ||||||
| using Mapster; | using Mapster; | ||||||
| using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||||
| using MongoDB.Driver; |  | ||||||
| using Core.Thalos.Provider.Contracts; |  | ||||||
| using MongoDB.Bson; | using MongoDB.Bson; | ||||||
| using System.Text.RegularExpressions; |  | ||||||
| using MongoDB.Bson.Serialization; | using MongoDB.Bson.Serialization; | ||||||
|  | using MongoDB.Driver; | ||||||
|  | using System.Reflection; | ||||||
|  | using System.Text.RegularExpressions; | ||||||
|  |  | ||||||
| namespace Core.Thalos.Provider.Providers.Onboarding | namespace Core.Thalos.Provider.Providers.Onboarding | ||||||
| { | { | ||||||
| @@ -25,19 +27,19 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|     public class UserProvider : IUserProvider |     public class UserProvider : IUserProvider | ||||||
|     { |     { | ||||||
|         private readonly CollectionRepository<UserAdapter> repository; |         private readonly CollectionRepository<UserAdapter> repository; | ||||||
|         //private readonly CacheSettings cacheSettings; | 		private readonly CacheSettings cacheSettings; | ||||||
|         //private readonly IRedisCacheProvider cacheProvider; | 		private readonly ICacheProvider cacheProvider; | ||||||
|  |  | ||||||
|         public UserProvider(CollectionRepository<UserAdapter> repository | 		public UserProvider(CollectionRepository<UserAdapter> repository, | ||||||
|         //IRedisCacheProvider cacheProvider,  |             ICacheProvider cacheProvider, | ||||||
|         //IOptions<CacheSettings> cacheSettings | 			IOptions<CacheSettings> cacheSettings | ||||||
|             ) |             ) | ||||||
|         { |         { | ||||||
|             this.repository = repository; |             this.repository = repository; | ||||||
|             this.repository.CollectionInitialization(); |             this.repository.CollectionInitialization(); | ||||||
|             //this.cacheSettings = cacheSettings.Value; | 			this.cacheSettings = cacheSettings.Value; | ||||||
|             //this.cacheProvider = cacheProvider; | 			this.cacheProvider = cacheProvider; | ||||||
|         } | 		} | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Creates a new User. |         /// Creates a new User. | ||||||
| @@ -62,14 +64,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<UserAdapter> GetUserById(string _id, CancellationToken cancellationToken) |         public async ValueTask<UserAdapter> GetUserById(string _id, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserById", _id); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserById", _id); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); |             var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); | ||||||
|  |  | ||||||
|             //if (cachedData is not null) { return cachedData; } |             //if (cachedData is not null) { return cachedData; } | ||||||
|  |  | ||||||
|             var user = await repository.FindByIdAsync(_id); |             var user = await repository.FindByIdAsync(_id); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, user); |             await cacheProvider.SetAsync(cacheKey, user); | ||||||
|  |  | ||||||
|             return user; |             return user; | ||||||
|         } |         } | ||||||
| @@ -81,14 +83,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<IEnumerable<UserAdapter>> GetAllUsers(CancellationToken cancellationToken) |         public async ValueTask<IEnumerable<UserAdapter>> GetAllUsers(CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllUsers"); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllUsers"); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<UserAdapter>>(cacheKey) ?? []; |             var cachedData = await cacheProvider.GetAsync<IEnumerable<UserAdapter>>(cacheKey) ?? []; | ||||||
|  |  | ||||||
|             //if (cachedData.Any()) return cachedData; |             if (cachedData.Any()) return cachedData; | ||||||
|  |  | ||||||
|             var users = await repository.AsQueryable(); |             var users = await repository.AsQueryable(); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, users); |             await cacheProvider.SetAsync(cacheKey, users); | ||||||
|  |  | ||||||
|             return users; |             return users; | ||||||
|         } |         } | ||||||
| @@ -101,8 +103,8 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<UserAdapter> GetUserByEmail(string? email, CancellationToken cancellationToken) |         public async ValueTask<UserAdapter> GetUserByEmail(string? email, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserByEmail", email); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserByEmail", email); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); |             var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); | ||||||
|  |  | ||||||
|             //if (cachedData is not null) { return cachedData; } |             //if (cachedData is not null) { return cachedData; } | ||||||
|  |  | ||||||
| @@ -110,7 +112,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|                 u => u.Email == email &&  |                 u => u.Email == email &&  | ||||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); |                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, user); |             await cacheProvider.SetAsync(cacheKey, user); | ||||||
|  |  | ||||||
|             return user; |             return user; | ||||||
|         } |         } | ||||||
| @@ -121,10 +123,10 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|         /// <param name="email">The User email.</param> |         /// <param name="email">The User email.</param> | ||||||
|         /// <returns>A <see cref="{Task{UserAdapter}}"/> representing |         /// <returns>A <see cref="{Task{UserAdapter}}"/> representing | ||||||
|         /// the asynchronous execution of the service.</returns> |         /// the asynchronous execution of the service.</returns> | ||||||
|         public async ValueTask<UserAdapter> ValidateUserExistence(string? email, CancellationToken cancellationToken) |         public async ValueTask<UserExistenceAdapter> ValidateUserExistence(string? email, CancellationToken cancellationToken) | ||||||
|         { |         { | ||||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserByEmail", email); |             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetUserByEmail", email); | ||||||
|             //var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); |             var cachedData = await cacheProvider.GetAsync<UserAdapter>(cacheKey); | ||||||
|  |  | ||||||
|             //if (cachedData is not null) { return cachedData; } |             //if (cachedData is not null) { return cachedData; } | ||||||
|  |  | ||||||
| @@ -132,9 +134,13 @@ namespace Core.Thalos.Provider.Providers.Onboarding | |||||||
|                 u => u.Email == email && |                 u => u.Email == email && | ||||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); |                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||||
|  |  | ||||||
|             //await cacheProvider.SetAsync(cacheKey, user); |             UserExistenceAdapter userExistance = new UserExistenceAdapter(); | ||||||
|  |  | ||||||
|             return user; |             userExistance.Existence = (user != null) ? true : false; | ||||||
|  |  | ||||||
|  |             await cacheProvider.SetAsync(cacheKey, userExistance); | ||||||
|  |  | ||||||
|  |             return userExistance; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales