public async Task <ProductQueryListView> GetAllProductTask(ProductViewListModel query) { ProductQueryListView queryList = new ProductQueryListView(); queryList.Count = GetAll().Include(x => x.Category).Count(); var prodAll = GetAll().Include(x => x.Category).Skip(query.Size * query.Page).Take(query.Size).ToList(); var list = new List <ProductViewModel>(); foreach (Product product in prodAll) { var prod = new ProductViewModel(); prod.Name = product.Name; prod.CategoryId = product.CategoryId; prod.ProductId = product.ProductId; prod.Price = product.Price; prod.Quantity = product.Quantity; prod.UnitMeasurement = product.UnitMeasurement; prod.Category = product.Category.CategoryName; list.Add(prod); } queryList.ProductviewModel = list.AsQueryable(); return(queryList); }
public async Task <ProductQueryListView> GeetAllProduct([FromBody] ProductViewListModel query) { var products = await this._repository.GetAllProductTask(query); return(products); }