Beispiel #1
0
        public async Task <object> Get(DanhGiaQuery query)
        {
            var danhGia = Sorting <DanhGia> .Get(Filtering(db.DanhGia, query), query);

            return(new
            {
                Total = danhGia.Count(),
                Content = await Paging <DanhGia> .Get(danhGia, query).ToListAsync()
            });
        }
Beispiel #2
0
        private IQueryable <DanhGia> Filtering(IQueryable <DanhGia> danhGia, DanhGiaQuery query)
        {
            if (query.IdSeller != -1)
            {
                danhGia = danhGia.Where(x => x.IdSeller == query.IdSeller);
                if (query.FromDanhGia != null)
                {
                    danhGia = danhGia.Where(x => x.Danhgia >= query.FromDanhGia);
                }
                if (query.ToDanhGia != null)
                {
                    danhGia = danhGia.Where(x => x.Danhgia <= query.ToDanhGia);
                }
            }
            else
            {
                danhGia = null;
            }

            return(danhGia);
        }
 public async Task <IActionResult> Get([FromQuery] DanhGiaQuery query)
 {
     return(Ok(await danhGiaService.Get(query)));
 }