예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }