public async Task <IActionResult> Get() { var pagination = Request.Headers["Pagination"]; if (!string.IsNullOrEmpty(pagination)) { string[] vals = pagination.ToString().Split(','); int.TryParse(vals[0], out page); int.TryParse(vals[1], out pageSize); } int currentPage = page; int currentPageSize = pageSize; var totalInstructors = await _rolesRepository.CountAsync(); var totalPages = (int)Math.Ceiling((double)totalInstructors / pageSize); IEnumerable <Role> roles = _rolesRepository .GetAllRoles() .Skip((currentPage - 1) * currentPageSize) .Take(currentPageSize) .ToList(); Response.AddPagination(page, pageSize, totalInstructors, totalPages); IEnumerable <RoleViewModel> coursesVM = Mapper.Map <IEnumerable <Role>, IEnumerable <RoleViewModel> >(roles); return(new OkObjectResult(coursesVM)); }
public List <Rol> GetRoles(SecurityContext securityContext) { var rolesList = new List <Rol>(); switch ((UserRoles)securityContext.User.RoleId) { case UserRoles.Customer: case UserRoles.Manager: case UserRoles.Salesman: rolesList = new List <Rol> { new Rol { RolId = securityContext.User.RoleId, Name = securityContext.User.Role } }; break; case UserRoles.SuperUser: case UserRoles.Administrator: rolesList = _rolesRepository.GetAllRoles(); break; } return(rolesList); }
public Task AddToRoleAsync(BL.Models.User user, string roleName, CancellationToken cancellationToken) { if (user == null) { throw new ArgumentNullException(nameof(user), "Parameter user is not set to an instance of an object."); } if (string.IsNullOrEmpty(roleName)) { throw new ArgumentNullException(nameof(roleName), "Parameter roleName is not set to an instance of an object."); } var role = Task.Run(() => _rolesRepository.GetAllRoles(), cancellationToken).Result.SingleOrDefault(e => e.NormalizedName == roleName); return(role != null ? _usersRolesRepository.AddToRoleAsync(_mapper.Map <DL.Models.User>(user), role.Id) : Task.FromResult <object>(null)); }
public IEnumerable <EmployeesRoles> GetAllRoles() { return(_rolesRepo.GetAllRoles()); }
public List <Roles> GetAllRoles(int limit, int offset, string order, string sort, string roleName, out int total) { return(_rolesRepository.GetAllRoles(limit, offset, order, sort, roleName, out total)); }
public List <RolesEntity> GetAllRoles() { return(roleRepository.GetAllRoles()); }
public IEnumerable <RoleDto> Get() { return(_rolesRepository.GetAllRoles()); }
public IActionResult GetAll() { return(Ok(repository.GetAllRoles())); }