public RoleSearchResponse SearchRoles(RoleSearchRequest request) { request = request ?? new RoleSearchRequest(); var result = new RoleSearchResponse(); using (var repository = _platformRepository()) { var query = repository.Roles; if (request.Keyword != null) { query = query.Where(r => r.Name.Contains(request.Keyword)); } result.TotalCount = query.Count(); var roles = query .OrderBy(r => r.Name) .Skip(request.SkipCount) .Take(request.TakeCount) .Include(r => r.RolePermissions.Select(rp => rp.Permission)) .ToArray(); result.Roles = roles.Select(r => r.ToCoreModel()).ToArray(); } return result; }
public IHttpActionResult SearchRoles(RoleSearchRequest request) { var result = _roleService.SearchRoles(request); return Ok(result); }