private BrandsProducts HandleParameters(String incId, String inlow, String inhigh) { try { int cId = Int32.Parse(incId); int low = Int32.Parse(inlow); int high = Int32.Parse(inhigh); List <Product> products = null; if (cId == 0) { products = serviceManager.SearchProductsByPriceRange(low, high); } else { products = serviceManager.SearchProductsByPRC(low, high, cId); } List <Brand> brands = viewModel.brands; BrandsProducts model = new BrandsProducts { products = products, brands = brands }; return(model); } catch (Exception e) { throw e; } }
// GET: Search public ActionResult Index(int index = 1) { String text = this.Request.Params.Get("text"); BrandsProducts model = HandleQuery(text); ViewBag.Text = text; return(View("Result", model)); }
public BrandsProducts GetViewModel() { List <Product> products = productService.All(); List <Brand> brands = brandService.All(); BrandsProducts viewModel = new BrandsProducts { products = products, brands = brands }; return(viewModel); }
public ActionResult Range(int index = 1) { try { BrandsProducts model = HandleParameters(Request.Params["cId"], Request.Params["low"], Request.Params["high"]); return(View("Result", model)); } catch (Exception) { return(RedirectToAction("Index")); } }
public ActionResult Index() { BrandsProducts b = new BrandsProducts { Brands = db.Brands.ToList(), VendorProducts = db.VendorProducts.ToList(), }; foreach (var vendorProduct in b.VendorProducts) { db.Entry(vendorProduct).Reference(p => p.Product).Load(); db.Entry(vendorProduct).Reference(v => v.Vendor).Load(); } return(View(b)); }
// GET: Sale public ActionResult Index() { BrandsProducts b = new BrandsProducts { Brands = db.Brands.ToList(), VendorProducts = db.VendorProducts.Where(p => p.Sale_price != 0).Where(p => p.Sale_price != null).ToList(), CategoriesList = db.Categories.ToList() }; foreach (var vendorProduct in b.VendorProducts) { db.Entry(vendorProduct).Reference(p => p.Product).Load(); db.Entry(vendorProduct).Reference(v => v.Vendor).Load(); } return(View(b)); }
private BrandsProducts HandleQuery(String text) { BrandsProducts model = null; if (!String.IsNullOrEmpty(text)) { List <Product> products = serviceManager.SearchProductsByName(text); List <Brand> brands = viewModel.brands; model = new BrandsProducts { products = products, brands = brands }; } else { model = viewModel; } return(model); }
public ActionResult Index() { BrandsProducts model = viewModel; return(View(model)); }
public HomeController() { serviceManager = ServiceManager.getInstance(); viewModel = serviceManager.GetViewModel(); }