public static async Task <IEnumerable <RouteElement> > GetRoutesForRole(string role, IRouteElementsRepository routeRepository) { var routesForRole = (await routeRepository.GetRouteElementsForRole(role)) .Select(route => { route.IsAccessable = true; return(route); }) .ToList(); var routesNotForRole = (await routeRepository.GetAllRouteElems()) .Except(routesForRole, new RouterElementComparer()); var allRoutes = routesNotForRole.Concat(routesForRole); return(allRoutes); }
public async Task EnsureUserRoleRouteElements() { foreach (var routes in StandartIdentityDataConstants.RoutesForRoles) { var role = await _roleManager.FindByNameAsync(routes.Role); var countElemsForRole = (await _routeElementRepository.GetRouteElementsForRole(role.Name)).Count; if (countElemsForRole == 0 || countElemsForRole < routes.RouteElements.Count) { _routeElementRepository.ClearRelationsBetweenRoleAndRouteElems(role.Id); await _routeElementRepository.SetRouteElementsForRole(role.Id, routes.RouteElements); } } }