public async Task <PagedResult <SlideViewModel> > GetAllPaging(PagingRequestBase request) { var query = from t in _context.Slides select t; int totalRow = await query.CountAsync(); var data = query.OrderBy(m => m.display_order) .Skip((request.PageIndex - 1) * request.PageSize) .Take(request.PageSize) .Select(a => new SlideViewModel() { id = a.id, display_order = a.display_order, status = a.status, image = a.image, create_at = a.create_at, link = a.link, update_at = a.update_at, }).ToListAsync(); var pageResult = new PagedResult <SlideViewModel>() { TotalRecords = totalRow, PageIndex = request.PageIndex, PageSize = request.PageSize, Items = await data, }; return(pageResult); }
public async Task <PagedResult <NewsViewModel> > GetAllNewsByPaging(PagingRequestBase request) { var query = from n in _context.News select new { n }; int totalRow = await query.CountAsync(); var data = await query.Skip((request.PageIndex - 1) *request.PageSize) .Take(request.PageSize) .Select(x => new NewsViewModel() { Id = x.n.Id, Title = x.n.Title, Summary = x.n.Summary, ImagePath = x.n.ImagePath, DateSubmitted = x.n.DateSubmitted }).ToListAsync(); var pagedResult = new PagedResult <NewsViewModel>() { TotalRecords = totalRow, Items = data }; return(pagedResult); }
public async Task <List <ProductViewModel> > GetProductByName(PagingRequestBase request) { var query = from p in _context.Products join pt in _context.ProductTranslations on p.Id equals pt.ProductId join pc in _context.ProductInCategories on p.Id equals pc.ProductId where pt.Name.Contains(request.keyword) select new { p, pt, pc }; var data = await query.Skip((request.PageIndex - 1) *request.PageSize).Take(request.PageSize).Select(x => new ProductViewModel() { Id = x.p.Id, Name = x.pt.Name, DateCreated = x.p.DateCreated, Description = x.pt.Description, Details = x.pt.Details, LanguageId = x.pt.LanguageId, OriginalPrice = x.p.OriginalPrice, Price = x.p.Price, SeoAlias = x.pt.SeoAlias, SeoDescription = x.pt.SeoDescription, SeoTitle = x.pt.SeoTitle, Stock = x.p.Stock, ViewCount = x.p.ViewCount }).ToListAsync(); return(data); }
public async Task <PagedResult <SlideViewModel> > GetSlidePagings(PagingRequestBase request) { var client = _httpClientFactory.CreateClient(); client.BaseAddress = new Uri(_configuration["BaseAddress"]); var respone = await client.GetAsync($"/api/slide/paging?pageIndex={request.PageIndex}&pageSize={request.PageSize}"); var body = await respone.Content.ReadAsStringAsync(); var slides = JsonConvert.DeserializeObject <PagedResult <SlideViewModel> >(body); return(slides); }
public async Task <IActionResult> Index(int pageIndex = 1, int pageSize = 10) { var request = new PagingRequestBase() { PageIndex = pageIndex, PageSize = pageSize, }; var data = await _slideApiClient.GetSlidePagings(request); if (TempData["result"] != null) { ViewBag.SuccessMsg = TempData["result"]; } if (TempData["error"] != null) { ViewBag.ErrorMsg = TempData["error"]; } return(View(data)); }
public async Task <IActionResult> Get([FromQuery] PagingRequestBase repuest) { var data = await _managerHoaDonService.GetAll(repuest); return(Ok(data)); }
public async Task <IActionResult> GetAllPaging([FromQuery] PagingRequestBase requet) { var slides = await _slideService.GetAllPaging(requet); return(Ok(slides)); }
public async Task <IActionResult> GetAllNewsByPaging(PagingRequestBase request) { var news = await _newsManagersService.GetAllNewsByPaging(request); return(Ok(news)); }
public async Task <IActionResult> GetByName(PagingRequestBase request) { var data = await _product.GetProductByName(request); return(Ok(data)); }
public async Task <PagedHoaDonByKyResult <HoaDonViewModel> > GetAll(PagingRequestBase repuest) { if (repuest.KyHoadon != null) { var query = await(from h in _context.HoaDon join k in _context.KhachHang on h.MaKh equals k.MaKh join x in _context.XaPhuong on k.XaPhuong equals x.MaXaPhuong join kt in _context.KyXuatHoaDon on h.KyTinh equals kt.MaKyTinh where h.TongTien > 0 && h.KyTinh.Value.Year == repuest.KyHoadon.Year && h.KyTinh.Value.Month == repuest.KyHoadon.Month && h.KyTinh.Value.Day == repuest.KyHoadon.Day select new HoaDonViewModel { RowId = h.RowId, MaHoaDon = h.MaHoaDon, KyTinh = h.KyTinh, MaKh = h.MaKh, TenKh = h.TenKh, ChiSoCu = h.ChiSoCu, ChiSoMoi = h.ChiSoMoi, SoM3 = h.SoM3, DonGiaTdm = h.DonGiaTdm, TienTdm = h.TienTdm, DonGiaVdm = h.DonGiaVdm, //TienVdm = h.TienVdm, //TienBaoTri = h.TienBaoTri, //TienThueBao = h.TienThueBao, Vat = h.Vat, ThanhTien = h.ThanhTien, NoKyTruoc = h.NoKyTruoc, TongTien = h.TongTien, //NgayLap = h.NgayLap, //NgayThu = h.NgayThu, //DaThanhToan = h.DaThanhToan, //NhanVienGhiNuoc =h.NhanVienGhiNuoc, //NhanVienThuTien = h.NhanVienThuTien, GhiChu = k.MaTram, //NguoiTao = h.NguoiTao, //NgayTao = h.NgayTao, //NguoiThayDoi = h.NguoiThayDoi, //NgayThayDoi = h.NgayThayDoi, //NguyenNhan = h.NguyenNhan, PhiNuocThai = h.PhiNuocThai, Dm10 = h.Dm10, Dm20 = h.Dm20, Dm30 = h.Dm30, Dm40 = h.Dm40, PhanLoaiNuocSd = h.PhanLoaiNuocSd, Don_Gia_DM10 = 0.0, Don_Gia_DM20 = 0.0, Don_Gia_DM30 = 0.0, Don_Gia_DM40 = 0.0, PhanTramPhiSH = 0.0, MSThue = k.MstKh, So_Nha = k.SoNha, To_KH = k.ToKh, Ap_KH = k.ApKh, Xa_Phuong = x.TenXaPhuong, Ky_Tinh_TuNgay = kt.DenNgay, Ky_Tinh_DenNgay = kt.TuNgay, }).Take(2).ToListAsync(); var totalcount = query.Count(); var result = new PagedHoaDonByKyResult <HoaDonViewModel>() { Items = query, TotalRecord = totalcount, KyHoaDon = repuest.KyHoadon }; return(result); } else { return(null); } }