// GET: Order/Edit/5 public ActionResult Edit() { string custName = Convert.ToString(TempData["CustName"]); int stoID = Convert.ToInt32(TempData["StoID"]); lib.Store sto = irepOrigSto.GetStores(stoID).First(); var viewMod = new Models.OrderViewMod() { custName = custName, stoLoc = sto.Loc }; TempData.Keep(); return(View(viewMod)); }
public ActionResult AddOrder() { int stoID = Convert.ToInt32(TempData["StoID"]); lib.Store sto = irepOrigSto.GetStores(stoID).First(); var viewMod = sto.iven.Select(i => new Models.IvenViewMod { merchID = i.Key.MerchID, merchName = i.Key.MerchName, merchPrice = i.Key.MerchPrice, quantity = i.Value }); TempData.Keep(); return(View(viewMod)); }
public ActionResult AddOrder(IFormCollection collection) { try { int stoID = Convert.ToInt32(TempData["StoID"]); int custID = Convert.ToInt32(TempData["CustID"]); lib.Store sto = irepOrigSto.GetStores(stoID).First(); lib.Customer cust = irepOrigCust.GetCustomers(cusid: custID).First(); lib.Order ord = new lib.Order(cust, sto, 0); irepOrig.Order(ord); irepOrig.EndMe(); ord = irepOrig.GetOrdersByCust(custID).Last(); foreach (var item in collection) { foreach (var iven in sto.iven) { if (iven.Key.MerchID == Convert.ToInt32(item.Key)) { var a = irepOrigMerch.GetMerch(iven.Key.MerchID).First(); ord.details.Add(a, Convert.ToInt32(item.Value)); break; } } } foreach (var item in ord.details) { sto.ChangeStock(item.Key, -1 * item.Value); } irepOrig.AddOrder(ord); TempData.Keep(); irepOrigSto.UpdateStore(sto); irepOrigSto.help(); irepOrig.EndMe(); return(RedirectToAction(nameof(EndOrder))); } catch { return(View()); } }