Fix some issues in the endpoints and use local mongodb
This commit is contained in:
		| @@ -28,15 +28,16 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     { | ||||
|         private readonly CollectionRepository<RoleAdapter> repository; | ||||
|         private readonly CacheSettings cacheSettings; | ||||
|         private readonly IRedisCacheProvider cacheProvider; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
|  | ||||
|         public RoleProvider(CollectionRepository<RoleAdapter> repository, | ||||
|         IRedisCacheProvider cacheProvider, IOptions<CacheSettings> cacheSettings) | ||||
|         //IRedisCacheProvider cacheProvider,  | ||||
|         IOptions<CacheSettings> cacheSettings) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             this.cacheSettings = cacheSettings.Value; | ||||
|             this.cacheProvider = cacheProvider; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
| @@ -62,14 +63,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         public async ValueTask<RoleAdapter> GetRoleById(string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); | ||||
|             var cachedData = await cacheProvider.GetAsync<RoleAdapter>(cacheKey); | ||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); | ||||
|             //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); | ||||
|  | ||||
|             await cacheProvider.SetAsync(cacheKey, role); | ||||
|             //await cacheProvider.SetAsync(cacheKey, role); | ||||
|  | ||||
|             return role; | ||||
|         } | ||||
| @@ -81,14 +82,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         public async ValueTask<IEnumerable<RoleAdapter>> GetAllRoles(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); | ||||
|             var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; | ||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); | ||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; | ||||
|  | ||||
|             if (cachedData.Any()) return cachedData; | ||||
|             //if (cachedData.Any()) return cachedData; | ||||
|  | ||||
|             var roles = await repository.AsQueryable(); | ||||
|  | ||||
|             await cacheProvider.SetAsync(cacheKey, roles); | ||||
|             //await cacheProvider.SetAsync(cacheKey, roles); | ||||
|  | ||||
|             return roles; | ||||
|         } | ||||
| @@ -133,7 +134,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         public async ValueTask<RoleAdapter> AddApplicationToRole(string roleId, ApplicationsEnum application, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var role = await repository.FindOneAsync( | ||||
|                 u => u.Id == roleId && | ||||
|                 u => u._Id == roleId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedApplications = role.Applications.Append(application).Distinct().ToArray(); | ||||
| @@ -153,7 +154,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         public async ValueTask<RoleAdapter> RemoveApplicationFromRole(string roleId, ApplicationsEnum application, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var role = await repository.FindOneAsync( | ||||
|                 u => u.Id == roleId && | ||||
|                 u => u._Id == roleId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedApplications = role.Applications | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales