public bool IsUserAuthorized(string controller, string action, string userName) { //ToDo: get user's role (based on the userName, maybe from the DB?) RoleSpecifications usersRole = RoleSpecifications.Admin; // get required role from the Matrix (this will fail if we haven't registered the requested controller/action combination RoleSpecifications requiredRole = SecurityMatrix.Matrix.First(x => x.Controller == controller && x.Action == action).MinimumRoleNeeded; return(usersRole >= requiredRole); }
public async Task <RolePaginationViewModel> GetByPage( RoleFilters filters, int currentPage, int pageSize, string orderByPropertyName, bool isAsc) { var specifications = new RoleSpecifications(filters.Name); var roles = await _roleRepository.GetAll().Where(specifications.Expression) .SortByProperty(orderByPropertyName, isAsc) .Skip(pageSize * (currentPage - 1)) .Take(pageSize).ToListAsync(); var total = _roleRepository.GetAll().Where(specifications.Expression).Count(); var results = roles.Select(x => _mapper.Map <RolePageViewModel>(x)).ToList(); return(new RolePaginationViewModel(results, currentPage, pageSize, total)); }