Beispiel #1
0
 public IQueryable <Branch> Search(IQueryable <Branch> query, BranchFilters filters)
 {
     if (!string.IsNullOrWhiteSpace(filters.Name))
     {
         query = query.Where(o => o.Name.Contains(filters.Name));
     }
     return(query);
 }
Beispiel #2
0
        public BranchFilters GetFilters()
        {
            var filters = new BranchFilters()
            {
                Page  = Convert.ToInt32(HttpContext.Request.Query["page"]),
                Limit = Convert.ToInt32(HttpContext.Request.Query["limit"]),
                Name  = HttpContext.Request.Query["name"],
            };

            return(filters);
        }
Beispiel #3
0
        public async Task <ResponseModel <BranchViewModel> > GetList(BranchFilters filters, SortCol sortCol, AccountViewModel current)
        {
            var query = _context.Branch.Where(o => o.Id != 0 && o.CompanyId == current.CompanyId);

            query = Search(query, filters);
            query = Sort(query, sortCol);
            var vms = await query.Skip((filters.Page - 1) *filters.Limit).Take(filters.Limit)
                      .ProjectTo <BranchViewModel>().ToListAsync();

            ResponseModel <BranchViewModel> result = new ResponseModel <BranchViewModel>();

            result.status  = 0;
            result.message = "";
            result.total   = query.Count();
            result.data    = vms;
            return(result);
        }