public IActionResult Confirm(OrderSubmitViewModel model) { var name = "Order"; var str = JsonConvert.SerializeObject(model); HttpContext.Session.SetString(name, str); return(View()); }
public async Task <IActionResult> Submit(int?id, OrderSubmitViewModel osvm) { if (id == null) { return(NotFound()); } if (ModelState.IsValid) { try { //get OrderSummary var order = await(from log in _context.OrderLog.Include("OrderList.Item.VendorItems.Vendor") where log.OrderSummaryId == id select log).SingleOrDefaultAsync(); if (order == null) { return(NotFound()); //Validate } //====EMAIL VENDORS HERE=================================== //========================================================= //Update OrderSummary order.Completed = true; order.Total = osvm.Total; _context.OrderLog.Update(order); //update context await _context.SaveChangesAsync(); //save context return(RedirectToAction("Index")); } catch (DbUpdateConcurrencyException) { throw; } } else { return(RedirectToAction("Index")); } }
public async Task <IActionResult> Submit(int?id) { if (id == null) { return(NotFound()); //Validate } //Get OrderSummary from context var order = await(from log in _context.OrderLog.Include("OrderList.Item.VendorItems.Vendor") where log.OrderSummaryId == id select log).SingleOrDefaultAsync(); if (order == null) { return(NotFound()); //Validate } //Create view model OrderSubmitViewModel osvm = new OrderSubmitViewModel(); osvm.Order = order; osvm.OrderSummaryId = order.OrderSummaryId; osvm.Total = order.CalculateTotal(); //Populate view model OrderItems foreach (var itemCount in order.OrderList) { List <ItemCount> tempList; //int key = itemCount.Item.DefaultVendorItem.Vendor.VendorId; var key = itemCount.Item.DefaultVendorItem.Vendor; if (!osvm.OrderItems.TryGetValue(key, out tempList)) //Key found in view model OrderItems { //Add new dictionary entry tempList = new List <ItemCount>(); osvm.OrderItems.Add(key, tempList); } //Add itemCount to OrderItems tempList.Add(itemCount); } return(View(osvm)); }