Beispiel #1
0
        public async Task <IActionResult> List(PagedSalesForm form)
        {
            var page = await _sales.GetList(form);

            form.Total = await _sales.Count(form);

            return(View(new PagedViewModel <HbSale, PagedSalesForm>(page, form)));
        }
Beispiel #2
0
        public async Task <int> Count(PagedSalesForm form)
        {
            var query = _dc.Sales.Where(u => !u.IsDeleted)
                        .Where(u => u.SaleDate > form.Start && u.SaleDate < form.End)
                        .AsQueryable();

            if (form.LotId.HasValue)
            {
                query = query.Where(u => u.LotId == form.LotId);
            }
            if (form.Type.HasValue)
            {
                query = query.Where(u => u.Type == form.Type);
            }

            return(await query.CountAsync());
        }
Beispiel #3
0
        public async Task <IEnumerable <HbSale> > GetList(PagedSalesForm form)
        {
            var query = _dc.Sales.Include(u => u.Lot)
                        .Where(u => !u.IsDeleted)
                        .Where(u => u.SaleDate > form.Start && u.SaleDate < form.End)
                        .AsQueryable();

            if (form.LotId.HasValue)
            {
                query = query.Where(u => u.LotId == form.LotId);
            }
            if (form.Type.HasValue)
            {
                query = query.Where(u => u.Type == form.Type);
            }

            var sales = await query.OrderByDescending(u => u.Id)
                        .Skip(form.Offset)
                        .Take(form.Count)
                        .ToArrayAsync();

            return(sales.Select(_mapper.Map <HbSale>).ToArray());
        }