private AllPagedProductsViewModel GetModel(int page, int producerId, string searchString, string value) { var allProducts = this.products .All(page, producerId, searchString, value) .To <AllProductsViewModel>() .ToList(); var productModel = new AllPagedProductsViewModel { Products = allProducts, Pagination = new PaginationViewModel { CurrentPage = page, ItemsPerPage = GlobalConstants.DefaultPageSize, TotalItems = producerId == 0 ? this.products.CountProducts(searchString) : this.products.CountProductsByProducer(producerId, searchString) }, ProducerId = producerId, Value = value, OrderByPrice = OrderByPrice(), Producers = GetAllProducers(), SearchString = searchString }; return(productModel); }
public ActionResult All(AllPagedProductsViewModel productModel) { int producerId = productModel.ProducerId; return View(GetModel(GlobalConstants.DefaultPage, producerId, productModel.SearchString, productModel.Value)); }
public ActionResult All(AllPagedProductsViewModel productModel) { int producerId = productModel.ProducerId; return(View(GetModel(GlobalConstants.DefaultPage, producerId, productModel.SearchString, productModel.Value))); }
private AllPagedProductsViewModel GetModel(int page, int producerId, string searchString, string value) { var allProducts = this.products .All(page, producerId, searchString, value) .To<AllProductsViewModel>() .ToList(); var productModel = new AllPagedProductsViewModel { Products = allProducts, Pagination = new PaginationViewModel { CurrentPage = page, ItemsPerPage = GlobalConstants.DefaultPageSize, TotalItems = producerId == 0 ? this.products.CountProducts(searchString) : this.products.CountProductsByProducer(producerId, searchString) }, ProducerId = producerId, Value = value, OrderByPrice = OrderByPrice(), Producers = GetAllProducers(), SearchString = searchString }; return productModel; }