public ActionResult Index() { ProductSearchModel _ProductViewModel = new ProductSearchModel { Sizes = processManager.GetSizes().Select(x => new SelectListItem { Value = x.SizeId.ToString(), Text = x.SizeName }), Brands = processManager.GetBrands().Select(x => new SelectListItem { Value = x.BrandId.ToString(), Text = x.BrandName }), Colours = processManager.GetColours().Select(x => new SelectListItem { Value = x.ColourId.ToString(), Text = x.ColourName }), Customers = processManager.GetCustomers().Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.CustomerName }), Products = processManager.GetProducts() }; return View(_ProductViewModel); }
public ActionResult Index(string searchString , int SizeID = -1, int BrandID = -1, int ColourID = -1, int CustomerID = -1) { ProductSearchParameters _Params = new ProductSearchParameters(); if (SizeID != -1) { _Params.SizeIds.Add(SizeID); } if (BrandID != -1) { _Params.BrandIds.Add(BrandID); } if (ColourID != -1) { _Params.ColourIds.Add(ColourID); } if (searchString.Length > 0) { _Params.SearchString = searchString; } ProductSearchModel _ProductViewModel = new ProductSearchModel { Sizes = processManager.GetSizes().Select(x => new SelectListItem { Value = x.SizeId.ToString(), Text = x.SizeName }), Brands = processManager.GetBrands().Select(x => new SelectListItem { Value = x.BrandId.ToString(), Text = x.BrandName }), Colours = processManager.GetColours().Select(x => new SelectListItem { Value = x.ColourId.ToString(), Text = x.ColourName }), Customers = processManager.GetCustomers().Select(x => new SelectListItem { Value = x.CustomerId.ToString(), Text = x.CustomerName }) }; if (CustomerID != -1) { _ProductViewModel.Products = processManager.CustomerProductSearch(CustomerID, _Params); } else { _ProductViewModel.Products = processManager.ProductSearch(_Params); } return View(_ProductViewModel); }