public PagedResponse <JawDto> Execute(JawSearch search) { var query = _context.Jaws.AsQueryable(); if (!string.IsNullOrEmpty(search.JawName) || !string.IsNullOrWhiteSpace(search.JawName)) { query = query.Where(x => x.JawName.ToLower().Contains(search.JawName.ToLower())); } var skipCount = search.PerPage * (search.Page - 1); var response = new PagedResponse <JawDto> { CurrentPage = search.Page, ItemsPerPage = search.PerPage, TotalCount = query.Count(), Items = query.Skip(skipCount).Take(search.PerPage).Select(x => new JawDto { Id = x.Id, JawName = x.JawName }).ToList() }; return(response); }
public IActionResult Get([FromQuery] JawSearch search, [FromServices] IGetJawQuery query) { return(Ok(_executor.ExecuteQuery(query, search))); }