public ActionResult Checkout() { var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>(); var model = new IndexViewModel() { Products = itemsInSession }; return this.View(model); }
public ActionResult Search(string searchCriteria) { Services.IProductRepository productRepository = new Services.ProductsRepository(); var products = string.IsNullOrEmpty(searchCriteria) ? productRepository.GetProducts() : productRepository.Search(searchCriteria); // add all products currently not in session var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>(); var filteredProducts = products.Where(item => !itemsInSession.Contains(item)); var model = new IndexViewModel() { Products = filteredProducts, SearchCriteria = searchCriteria }; return this.View("Index", model); }