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() }); }
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))); }