// Add the order, pass the session variable info to the db public ActionResult AddOrder() { // they can't add a order if they're not logged on if (HttpContext.Session.GetString(SessionVars.User) == null) { return(Redirect("/Login")); } ShoppingCartModel model = new ShoppingCartModel(_db); int retVal = -1; string retMessage = ""; try { Dictionary <string, object> trayItems = HttpContext.Session.GetObject <Dictionary <string, object> >(SessionVars.ShoppingCart); retVal = model.AddOrder(trayItems, HttpContext.Session.GetString(SessionVars.User)); if (retVal > 0) // Tray Added { retMessage = "Order " + retVal + " Created!"; } else // problem { retMessage = "Order not added, try again later"; } } catch (Exception ex) // big problem { retMessage = "Order was not created, try again later! - " + ex.Message; } HttpContext.Session.Remove(SessionVars.ShoppingCart); // clear out current tray once persisted HttpContext.Session.SetString(SessionVars.Message, retMessage); return(Redirect("/Home")); }