Пример #1
0
        public async Task <object> GetByCustomer(int idUser, HoaDonQuery query)
        {
            var hoaDon = Sorting <HoaDon> .Get(Filtering(db.HoaDon.Where(x => x.IdUser == idUser), query), query);

            return(new {
                Total = hoaDon.Count(),
                Content = await Paging <HoaDon> .Get(hoaDon, query).Include(x => x.ChiTietHD).ToListAsync()
            });
        }
Пример #2
0
        public async Task <object> GetBySeller(int idSeller, HoaDonQuery query)
        {
            var hoaDon = Sorting <HoaDon> .Get(Filtering(db.HoaDon.Where(x => x.IDSeller == idSeller), query), query);

            return(new
            {
                Total = hoaDon.Count(),
                Content = await GetBySeller(Paging <HoaDon> .Get(hoaDon, query).Include(x => x.ChiTietHD))
            });
        }
Пример #3
0
        private IQueryable <HoaDon> Filtering(IQueryable <HoaDon> hoaDon, HoaDonQuery query)
        {
            if (query.IDUser != null)
            {
                hoaDon = hoaDon.Where(x => x.ID == query.IDUser);
            }
            if (query.IDSeller != null)
            {
                hoaDon = hoaDon.Where(x => x.IDSeller == query.IDSeller);
            }
            if (query.TenKH != null)
            {
                hoaDon = from x in hoaDon
                         where x.TenKH.Contains(query.TenKH)
                         select x;
            }
            if (query.Mail != null)
            {
                hoaDon = from x in hoaDon
                         where x.Mail.Contains(query.Mail)
                         select x;
            }
            if (query.SDT != null)
            {
                hoaDon = from x in hoaDon
                         where x.SDT.Contains(query.SDT)
                         select x;
            }
            if (query.PhuongThucTT != null)
            {
                hoaDon = from x in hoaDon
                         where x.PhuongThucTT.Contains(query.PhuongThucTT)
                         select x;
            }
            if (query.TinhTrangTT != null)
            {
                hoaDon = from x in hoaDon
                         where x.TinhTrangTT.Contains(query.TinhTrangTT)
                         select x;
            }
            if (query.TrangThai != null)
            {
                hoaDon = hoaDon.Where(x => x.TrangThai == query.TrangThai);
            }
            if (query.FromDate != null)
            {
                hoaDon = hoaDon.Where(x => x.Ngay >= query.FromDate);
            }
            if (query.ToDate != null)
            {
                hoaDon = hoaDon.Where(x => x.Ngay <= query.ToDate);
            }

            return(hoaDon);
        }
Пример #4
0
        public async Task <IActionResult> GetBySeller([FromQuery] HoaDonQuery query)
        {
            int idSeller = User.GetIdSeller();

            return(Ok(await hoaDonService.GetBySeller(idSeller, query)));
        }