public async Task <IEnumerable <RoleModel> > GetAllRoles() { const string cacheKey = "roles"; var cachedResponse = await _redisCacheService.GetCachedData <IEnumerable <RoleModel> >(cacheKey); if (cachedResponse != null) { return(cachedResponse); } var roles = await _misService.GetAllRoles(); await _redisCacheService.SetCacheData(cacheKey, roles, TimeSpan.FromSeconds(86400)); return(roles); }
public async Task <IEnumerable <AccessGroupAssignmentModel> > GetAll() { var accessGroupAssignments = await _accessGroupAssignmentRepository.GetAll(); var departments = await _misService.GetAllDepartments(); var roles = await _misService.GetAllRoles(); var positions = await _misService.GetPositions(); var applications = await _ssoService.GetAllApplications(); return(await Task.FromResult( from accessGroupAssignment in accessGroupAssignments join department in departments on accessGroupAssignment.AccessGroup.DepartmentId equals department.DepartmentId into dep from department in dep.DefaultIfEmpty() join application in applications on accessGroupAssignment.AccessGroup.ApplicationId equals application.ApplicationId join position in positions on accessGroupAssignment.PositionId equals position.PositionId into position from pos in position.DefaultIfEmpty() join role in roles on accessGroupAssignment.RoleId equals role.RoleId into role from rol in role.DefaultIfEmpty() select new AccessGroupAssignmentModel { AccessGroupAssignmentId = accessGroupAssignment.AccessGroupAssignmentId, AccessGroupId = accessGroupAssignment.AccessGroupId, Name = accessGroupAssignment.AccessGroup.Name, ApplicationId = accessGroupAssignment.AccessGroup.ApplicationId, ApplicationName = application.ApplicationName, DepartmentId = department?.DepartmentId ?? 0, DepartmentName = department?.DepartmentName ?? string.Empty, RoleId = accessGroupAssignment.RoleId, RoleName = rol?.RoleName ?? string.Empty, PositionId = accessGroupAssignment.PositionId, PositionName = pos?.PositionName ?? string.Empty, PersonId = accessGroupAssignment.PersonId, LastUpdatedBy = accessGroupAssignment.LastUpdatedBy, })); }