public IActionResult Index() { WinkelwagenViewModel cart = new WinkelwagenViewModel(); try { foreach (Product p in SessionHelper.GetObjectFromJson <List <Product> >(HttpContext.Session, "cart")) { cart.Producten.Add(p); } } catch { return(View()); } return(View(cart)); }
public IActionResult Index(WinkelwagenViewModel vm) { Bestelling bestelling = new Bestelling { KlantId = GetUserId() }; bestelling = ConstructBestelling(bestelling); long result = bestellingRepository.Insert(bestelling); if (result != -1) { HttpContext.Session.Clear(); return(RedirectToAction("Geplaatst")); } return(RedirectToAction("Mislukt")); }
public IActionResult Index() { WinkelwagenViewModel cart = new WinkelwagenViewModel(); try { foreach (Product p in SessionHelper.GetObjectFromJson <List <Product> >(HttpContext.Session, "cart")) { cart.Producten.Add(p); cart.TotaalPrijs = cart.TotaalPrijs + Convert.ToDecimal(Convert.ToDecimal(p.Prijs) * p.Aantal); } } catch { return(View()); } return(View(cart)); }