public async Task <ProductsPagingResponse <VM_Product> > GetAllProductPaging(GetAllProductAPI request) { ProductsPagingResponse <VM_Product> response = null; var query = _context.Products.Include(x => x.ImageProducts).Include(x => x.Category); var result = await query.Select(x => new VM_Product() { Id = x.Id, Name = x.Name, Price = x.Price, Quantity = x.Quantity, Decription = x.Decription, CategoryId = x.Category.Id, CategoryName = x.Category.Name, OriginalPrice = x.OriginalPrice, ImageProducts = x.ImageProducts }).ToListAsync(); response = new ProductsPagingResponse <VM_Product>() { Items = result }; return(response); }
public async Task <IActionResult> GetAllProductPagging([FromQuery] GetAllProductAPI request) { var result = await _productService.GetAllProductPaging(request); return(Ok(result)); }