public async Task <EnableRoleResponse> EnableRole(EnableRoleRequest request) { var session = await _sessionService.GetAuthenticatedSession(); var response = new EnableRoleResponse(); var roles = await _cache.Roles(); var role = roles.FirstOrDefault(u => u.Id == request.Id); using (var uow = _uowFactory.GetUnitOfWork()) { await uow.UserRepo.EnableRole(new Infrastructure.Repositories.UserRepo.Models.EnableRoleRequest() { Id = role.Id, Updated_By = session.User.Entity.Id }); uow.Commit(); } _cache.Remove(CacheConstants.Roles); await _sessionService.WriteSessionLogEvent(new Models.ServiceModels.Session.CreateSessionLogEventRequest() { EventKey = SessionEventKeys.RoleEnabled }); response.Notifications.Add($"Role '{role.Name}' has been enabled", NotificationTypeEnum.Success); return(response); }
public async Task <EnableRoleResponse> EnableRole(EnableRoleRequest request) { var sessionUser = await _sessionManager.GetUser(); var response = new EnableRoleResponse(); var roles = await _cache.Roles(); var role = roles.FirstOrDefault(u => u.Id == request.Id); using (var uow = _uowFactory.GetUnitOfWork()) { await uow.UserRepo.EnableRole(new Repositories.DatabaseRepos.UserRepo.Models.EnableRoleRequest() { Id = role.Id, Updated_By = sessionUser.Id }); uow.Commit(); } _cache.Remove(CacheConstants.Roles); await _sessionManager.WriteSessionLogEvent(new Models.ManagerModels.Session.CreateSessionLogEventRequest() { EventKey = SessionEventKeys.RoleEnabled, Info = new Dictionary <string, string>() { { "Role_Id", request.Id.ToString() } } }); response.Notifications.Add($"Role '{role.Name}' has been enabled", NotificationTypeEnum.Success); return(response); }