public IQueryable <Measure> Search(IQueryable <Measure> query, MeasureFilters filters) { if (!string.IsNullOrWhiteSpace(filters.Name)) { query = query.Where(o => o.MeasureName.Contains(filters.Name)); } return(query); }
public MeasureFilters GetFilters() { var filters = new MeasureFilters() { Page = Convert.ToInt32(HttpContext.Request.Query["page"]), Limit = Convert.ToInt32(HttpContext.Request.Query["limit"]), Name = HttpContext.Request.Query["name"], Code = HttpContext.Request.Query["code"], }; return(filters); }
public async Task <ResponseModel <MeasureViewModel> > GetList(MeasureFilters filters, SortCol sortCol, AccountViewModel account) { var query = _context.Measure.Where(o => o.CompanyId == account.CompanyId); query = Search(query, filters); query = Sort(query, sortCol); var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit) .ProjectTo <MeasureViewModel>().ToListAsync(); ResponseModel <MeasureViewModel> result = new ResponseModel <MeasureViewModel>(); result.status = 0; result.message = ""; result.total = query.Count(); result.data = vms; return(result); }