// GET: Order public ActionResult Index() { OrderWeb weborder = new OrderWeb(); //var libUsers = Repo.Get(search); //var webRests = libRests.Select(x => new Restaurant return(View(weborder)); }
// GET: Order/Create public ActionResult Create(int locId, int pizzaCt) { OrderWeb getOrder = new OrderWeb { LocationId = locId, PizzaCount = pizzaCt }; return(View(getOrder)); }
public ActionResult PlaceOrder(string numP, string loc, int lastId) { TempData["numP"] = numP; TempData["loc"] = loc; TempData["lastId"] = lastId; OrderWeb order = new OrderWeb { PizzaCountInt = Convert.ToInt32(numP) }; // if (lastId != null) // { order.OrderId = lastId; // } //logic to display suggested order //need parameter last order id //if order history doesnt exist then lastId will be 0 //take id and get order if (order.OrderId != 0) { //grab pizza ids from order pizza table List <Library.Models.Pizza> pizzaList = Repo.FindPizzasInOrderPizzaByOrderID(order.OrderId); order.PizzaCountDetails = pizzaList.Count(); //fill out pizzadictionary List <bool> ToppingList = new List <bool>(); ToppingList.Add(false); ToppingList.Add(false); for (int i = 0; i < order.PizzaCountDetails; i++) { order.PizzaDictionary.Add(i, ToppingList); } for (int i = 0; i < order.PizzaCountDetails; i++) { List <bool> OrderToppingList = new List <bool>(); OrderToppingList.Add(pizzaList[i].Pepperoni); OrderToppingList.Add(pizzaList[i].ExtraCheese); order.PizzaDictionary[i] = OrderToppingList; } return(View(order)); //develop logic to grab pizza count from order pizza table //create pizza dictionary from count and ids //put logic in html to print pizzas based on dictionary //add this logic to order details and maybe order history by location and user } //fill out details. (details will be overwritten in post action or because they arent part of the form they go away?) return(View(order)); }
public ActionResult SortSelection(OrderWeb order) { try { return(RedirectToAction("OrderHistory", "Order", new { sortID = order.sortSelect })); } catch { return(View()); } }
public ActionResult SuggestedOrderView(string myTextBox) { Order sss; User placeholderforusername = dl.Unub(myTextBox); if (placeholderforusername.userorderhistory.Count == 0) { sss = new Order() { cheesepizza = 1, pepperonipizza = 1, sausagepizza = 1 }; } else { sss = dl.OID(placeholderforusername.userorderhistory.Last()); } TempData["username"] = myTextBox; var owo = new OrderWeb { locationID = sss.locationID, username = sss.username, ordertime = sss.ordertime, cheesepizza = sss.cheesepizza, pepperonipizza = sss.pepperonipizza, sausagepizza = sss.sausagepizza, currentprice = sss.currentprice, orderID = sss.orderID }; List <Order> ol = or.GetOrders().Where(q => q.username.Equals(myTextBox)).ToList(); List <OrderWeb> owl = new List <OrderWeb>(); foreach (var oml in ol) { owl.Add(new OrderWeb { locationID = sss.locationID, username = sss.username, ordertime = sss.ordertime, cheesepizza = sss.cheesepizza, pepperonipizza = sss.pepperonipizza, sausagepizza = sss.sausagepizza, currentprice = sss.currentprice, orderID = sss.orderID }); } return(View(owl)); }
public OrderWeb GetOrderByDateTime(DateTime dt) { var order = _db.OrderHistory; OrderWeb orderNow = null; foreach (var item in order) { orderNow = Mapper.Map(item); } return(orderNow); }
public ActionResult StartOrder(OrderWeb order) { try { TempData["PizzaCount"] = order.PizzaCount; return(RedirectToAction("Create", "Order", new { locId = order.LocationId, pizzaCt = order.PizzaCount })); } catch { return(View()); } }
// GET: Order public ActionResult Index() { /*if (TempData.Peek("id").Equals(null)) //redirect to login * { * RedirectToAction("Index", "User"); * }*/ OrderWeb order = new OrderWeb(); //suggested order logic return(View(order)); }
public ActionResult Index(OrderWeb order) { // var CurrentOrder = new OrderWeb { PizzaCount = order.PizzaCount, Address = order.Address }; // Session["Order"] = CurrentOrder; // HttpContext.Session.Set("order", CurrentOrder); if (TempData.Peek("id") == null) //redirect to login { ModelState.AddModelError("", "Please login before placing an order"); return(View(order)); } else { //datetime logic var currentTime = DateTime.Now; TimeSpan span; var OrderList = Repo.GetOrders(); var userId = (int)TempData.Peek("id"); string FirstName = Repo.FindFirstNameById(userId); string LastName = Repo.FindLastNameById(userId); var userHistory = Library.Models.Order.CreateUserOrderHistory(OrderList, FirstName, LastName); var userHistoryAtLocation = Library.Models.Order.CreateLocationOrderHistory(userHistory, order.Address); if (userHistoryAtLocation.Count > 0) { var LastOrder = Library.Models.Order.FindLastOrderFromUserFromLocation(userHistoryAtLocation); span = currentTime.Subtract(LastOrder.OrderTime); if (span.TotalHours < 2) { ModelState.AddModelError("", "Sorry you cannot place an order from the same location within two hours"); return(View(order)); } } //pass last order id and print suggested order on place order //get last order logic if (userHistory.Count > 0) //if user has an order history { var LastOrder = Library.Models.Order.FindLastOrderFromUserFromLocation(userHistory); return(RedirectToAction("PlaceOrder", "Order", new { numP = order.PizzaCountString, loc = order.Address, lastId = LastOrder.OrderID })); } else { return(RedirectToAction("PlaceOrder", "Order", new { numP = order.PizzaCountString, loc = order.Address, lastId = 0 })); } //redirect to next part of the order with the data you have. PizzaCount and location (which can make a location id) } }
public ActionResult PlaceOrder(OrderWeb Ordertoplace) { return(View()); }
public void AddOrder(OrderWeb order) { _db.Add(Mapper.Map(order)); }
// GET: Order/SortSelection public ActionResult SortSelection() { OrderWeb order = new OrderWeb(); return(View(order)); }
// GET: Order/OrderConfirmation/5 public ActionResult OrderConfirmation(DateTime dateTime) { OrderWeb order = Repo.GetOrderByDateTime(dateTime); var loc = Repo.GetLocationById(order.LocationId); TempData["LocationName"] = loc.Name; var cust = Repo.GetCustomerById(order.CustomerId); TempData["CustomerFirstName"] = cust.firstName; TempData["CustomerLastName"] = cust.lastName; //pizza1 if (order.Pizza1Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza1Id); TempData["Pizza1"] = pizza.Name; } else { TempData["Pizza1"] = "noPizza"; } //pizza2 if (order.Pizza2Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza2Id); TempData["Pizza2"] = pizza.Name; } else { TempData["Pizza2"] = "noPizza"; } //pizza3 if (order.Pizza3Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza3Id); TempData["Pizza3"] = pizza.Name; } else { TempData["Pizza3"] = "noPizza"; } //pizza4 if (order.Pizza4Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza4Id); TempData["Pizza4"] = pizza.Name; } else { TempData["Pizza4"] = "noPizza"; } //pizza5 if (order.Pizza5Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza5Id); TempData["Pizza5"] = pizza.Name; } else { TempData["Pizza5"] = "noPizza"; } //pizza6 if (order.Pizza6Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza6Id); TempData["Pizza6"] = pizza.Name; } else { TempData["Pizza6"] = "noPizza"; } //pizza7 if (order.Pizza7Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza7Id); TempData["Pizza7"] = pizza.Name; } else { TempData["Pizza7"] = "noPizza"; } //pizza8 if (order.Pizza8Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza8Id); TempData["Pizza8"] = pizza.Name; } else { TempData["Pizza8"] = "noPizza"; } //pizza9 if (order.Pizza9Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza9Id); TempData["Pizza9"] = pizza.Name; } else { TempData["Pizza9"] = "noPizza"; } //pizza10 if (order.Pizza10Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza10Id); TempData["Pizza10"] = pizza.Name; } else { TempData["Pizza10"] = "noPizza"; } //pizza11 if (order.Pizza11Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza11Id); TempData["Pizza11"] = pizza.Name; } else { TempData["Pizza11"] = "noPizza"; } //pizza12 if (order.Pizza12Id != 0) { var pizza = Repo.GetPizzaById(order.Pizza12Id); TempData["Pizza12"] = pizza.Name; } else { TempData["Pizza12"] = "noPizza"; } return(View(order)); }
// GET: Order public ActionResult Index() { OrderWeb order = new OrderWeb(); return(View(order)); }
public ActionResult Create([Bind("LocationId,PizzaCount")] OrderWeb getOrder) { try { //order.LocationId = (int)TempData.Peek("LocationID"); //order.PizzaCount = (int)TempData.Peek("PizzaCount"); OrderWeb order = new OrderWeb(); order.LocationId = getOrder.LocationId; order.PizzaCount = getOrder.PizzaCount; order.CustomerId = (int)TempData.Peek("CustomerId"); order.Dt = DateTime.Now; order.Total = 0; //kick customer back to StarOrder if they placed an order at this location in the last 2 hours var orderList = Repo.GetOrderHistoryByCustomerId(order.CustomerId); List <OrderWeb> orderHistory = Repo.GetOrderHistoryByLocationId(order.LocationId, orderList); //custLocOrderHist is the order history of a specific customer at a specific location sorted from newest to oldest IEnumerable <OrderWeb> custLocOrderHist = orderHistory.OrderByDescending(x => x.Dt); OrderWeb newest = custLocOrderHist.First(); TimeSpan timeSpan = order.Dt.Subtract(newest.Dt); if (order.LocationId == newest.LocationId) { if (timeSpan.Hours < 2) { ModelState.AddModelError("", "Unable to submit order. Cannot order from the same location within two hours of the previous order."); return(RedirectToAction("StartOrder", "Order")); } } //populate total for (int i = 0; i < order.PizzaCount; i++) { var pizza = Repo.GetPizza(order.PizzaId[i], order.PizzaSize[i]); order.Total += pizza.Cost; } //if order is over $500, redirect to order page if (order.Total > 500) { return(RedirectToAction("Create", "Order")); } //create inventory list to apply aggregate sum function to for final inventory decrimentor List <int[]> invDec = new List <int[]>(); //get current inventory for location List <InventoryWeb> LocInv = new List <InventoryWeb>(); LocInv = Repo.GetInventoryByLocation(order.LocationId); int[] locationInv = new int[13]; foreach (var item in LocInv) { for (int i = 0; i < locationInv.Length; i++) { locationInv[i] = item.Quantity.GetValueOrDefault(); } } //Pizza1ID try { if (order.PizzaId[0] > 0) { order.Pizza1Id = order.PizzaId[0]; if (order.Pizza1Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza1Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza1Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza1Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza1Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza1Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza2ID try { if (order.PizzaId[1] > 0) { order.Pizza2Id = order.PizzaId[1]; if (order.Pizza2Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza2Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza2Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza2Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza2Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza2Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza3ID try { if (order.PizzaId[2] > 0) { order.Pizza3Id = order.PizzaId[2]; if (order.Pizza3Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza3Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza3Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza3Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza3Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza3Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza4ID try { if (order.PizzaId[3] > 0) { order.Pizza4Id = order.PizzaId[3]; if (order.Pizza4Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza4Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza4Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza4Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza4Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza4Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza5ID try { if (order.PizzaId[4] > 0) { order.Pizza5Id = order.PizzaId[4]; if (order.Pizza5Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza5Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza5Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza5Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza5Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza5Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza6ID try { if (order.PizzaId[5] > 0) { order.Pizza6Id = order.PizzaId[5]; if (order.Pizza6Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza6Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza6Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza6Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza6Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza6Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza7ID try { if (order.PizzaId[6] > 0) { order.Pizza7Id = order.PizzaId[6]; if (order.Pizza7Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza7Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza7Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza7Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza7Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza7Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza8ID try { if (order.PizzaId[7] > 0) { order.Pizza8Id = order.PizzaId[7]; if (order.Pizza8Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza8Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza8Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza8Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza8Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza8Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza9ID try { if (order.PizzaId[8] > 0) { order.Pizza9Id = order.PizzaId[8]; if (order.Pizza9Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza9Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza9Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza9Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza9Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza9Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza10ID try { if (order.PizzaId[9] > 0) { order.Pizza10Id = order.PizzaId[9]; if (order.Pizza10Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza10Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza10Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza10Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza10Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza10Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza11ID try { if (order.PizzaId[10] > 0) { order.Pizza11Id = order.PizzaId[10]; if (order.Pizza11Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza11Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza11Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza11Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza11Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza11Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //Pizza12ID try { if (order.PizzaId[11] > 0) { order.Pizza12Id = order.PizzaId[11]; if (order.Pizza12Id == 1) { invDec.Add(order.CheeseInv); } else if (order.Pizza12Id == 2) { invDec.Add(order.PepperoniInv); } else if (order.Pizza12Id == 3) { invDec.Add(order.MeatLoversInv); } else if (order.Pizza12Id == 4) { invDec.Add(order.VeggieInv); } else if (order.Pizza12Id == 5) { invDec.Add(order.HawaiianInv); } else if (order.Pizza12Id == 6) { invDec.Add(order.GoldenSunInv); } } } catch { } //add up all inventory to one array int[] invTotal = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; foreach (int[] item in invDec) { int len = item.Length; for (int i = 0; i < len; i++) { invTotal[i] += item[i]; } } //remove invTotal from locInv (inventory management). If below 0, reject order. int leng = invTotal.Length; for (int i = 0; i < leng; i++) { locationInv[i] -= invTotal[i]; } bool invCheck = true; foreach (int item in locationInv) { if (item < 0) { invCheck = false; } } if (invCheck == true) { //submit inventory to DB int iterator = 0; foreach (var item in LocInv) { item.Quantity = locationInv[iterator]; iterator++; } try { foreach (var item in LocInv) { Repo.UpdateInventory(item); } } catch { ModelState.AddModelError("", "Unable to update inventory."); } //submit order to DB Repo.AddOrder(order); Repo.Save(); return(RedirectToAction("OrderConfirmation", "Order", new { dateTime = order.Dt })); } else { ModelState.AddModelError("", "Unable to submit order. Insufficient inventory."); return(RedirectToAction("StartOrder", "Order")); } } catch { return(View(getOrder)); } }
public ActionResult PlaceOrder(string[] ToppingListForm, OrderWeb order) { string numP = (string)TempData.Peek("numP"); string loc = (string)TempData.Peek("loc"); order.PizzaCountString = numP; //this is a string need to convert to int order.Address = loc; order.PizzaCountInt = Convert.ToInt32(numP); List <bool> ToppingList = new List <bool>(); for (int i = 0; i < order.NumOfToppings; i++) { ToppingList.Add(false); } for (int i = 0; i < order.PizzaCountInt; i++) { order.PizzaDictionary.Add(i, ToppingList); } int boolIndex = 0; for (int x = 0; x < order.PizzaCountInt; x++) { List <bool> OrderToppingList = new List <bool>(); for (int i = 0; i < order.NumOfToppings; i++) { if (ToppingListForm[boolIndex] == "true") { OrderToppingList.Add(true); boolIndex++; } else { OrderToppingList.Add(false); } boolIndex++; } order.PizzaDictionary[x] = OrderToppingList; } //inventory logic order.LocationId = Repo.GetLocationIdByName(order.Address); //get inventory from db by location id (for pizza and cheese) var PepperoniInventory = Repo.GetLocationPepperoniInventoryById(order.LocationId); var CheeseInventory = Repo.GetLocationCheeseInventoryById(order.LocationId); for (int x = 0; x < order.PizzaCountInt; x++) { order.PizzaIDs.Add(Repo.FindPizzaIdByToppings(order.PizzaDictionary[x])); } //subtract for each topping on each pizza for (int x = 0; x < order.PizzaCountInt; x++) //pepperoni first { if (order.PizzaDictionary[x][0]) { PepperoniInventory -= 1; } if (order.PizzaDictionary[x][1]) { CheeseInventory -= 1; } } //check if less than 0 if ((PepperoniInventory < 0) || (CheeseInventory < 0)) { ModelState.AddModelError("", "Sorry we do not have enough inventory at this location to create your order"); return(View(order)); } //if less than 0 add it back and return view //ModelState.AddModelError("", "Sorry we do not have enough inventory at this location to create your order"); //return View(order); order.OrderTime = DateTime.Now; order.UserId = (int)TempData.Peek("id"); decimal runningTotal = 0.00m; foreach (var id in order.PizzaIDs) { runningTotal += Repo.FindPriceByPizzaID(id); } order.TotalPrice = runningTotal; if ((Decimal.Compare(runningTotal, 500.00m)) > 0) //compare to $500 { ModelState.AddModelError("", "Sorry we cannot accept your order, it exceeds $500"); return(View(order)); } var libOrder = MapperWeb.Map(order); var location = new Library.Models.Location { LocationID = order.LocationId, Address = Repo.GetLocationNameById(order.LocationId), PepperoniInventory = PepperoniInventory, CheeseInventory = CheeseInventory }; Repo.UpdateLocationInventory(location); Repo.Save(); Repo.AddOrder(libOrder); Repo.Save(); order.OrderId = Repo.GetOrderIdByDateTime(order.OrderTime); foreach (var id in order.PizzaIDs) { Repo.AddOrderPizzas(order.OrderId, id); } Repo.Save(); return(RedirectToAction("OrderDetails", "Order", new { orderId = order.OrderId })); }
public ActionResult Index(OrderWeb ordertoplace) { int herndoninventoryfromdb = Repo.getHerndonInventory(); int restoninventoryfromdb = Repo.getRestonInventory(); int userID = (int)TempData["CurrentUserID"]; UserWeb currentuser = new UserWeb(); LocationWeb location = new LocationWeb(); //List<MainLibrary.Models.Order> allOrders = Repo.GetOrders().Reverse().ToList(); //foreach (MainLibrary.Models.Order order in allOrders) //{ // if(order.User.UserID == userID) // { // TimeSpan diff = DateTime.Now - order.TimeOfOrder; // if (diff.TotalHours > 2) // { // ModelState.AddModelError("", "You ordered less than two hours ago!!!!"); // TempData["CurrentUserID"] = userID; // break; // } // } //} string userStore = Repo.getUserStore(userID); location.StoreName = userStore; if (userStore == "Reston") { location.LocID = 2; location.StoredPizza = Repo.getRestonInventory(); } else if (userStore == "Herndon") { location.StoredPizza = Repo.getHerndonInventory(); location.LocID = 1; } string firstName = Repo.getFirstName(userID); string lastName = Repo.getLastName(userID); currentuser.setUser(firstName, lastName, userStore, userID); ordertoplace.Location = location; ordertoplace.User = currentuser; if (Decimal.Compare(ordertoplace.CalcOrderPrice(), 500.0m) > 0) { ModelState.AddModelError("", "That is more than $500!!!!"); TempData["CurrentUserID"] = userID; return(View(ordertoplace)); } if (userStore == "Herndon") { if ((herndoninventoryfromdb - ordertoplace.amountDough()) < 0) { ModelState.AddModelError("", "Not enough inventory left from Herndon please order less!!!!"); TempData["CurrentUserID"] = userID; } else { Repo.AddOrder(Mapper.Map(ordertoplace)); Repo.SaveChanges(); Repo.removeFromHerndonInv(ordertoplace.amountDough()); Repo.SaveChanges(); return(RedirectToAction("Index", "")); } } else if (userStore == "Reston") { if ((restoninventoryfromdb - ordertoplace.amountDough()) < 0) { ModelState.AddModelError("", "Not enough inventory left from Reston please order less!!!!"); TempData["CurrentUserID"] = userID; } else { int doughtosubtract = ordertoplace.amountDough(); Repo.AddOrder(Mapper.Map(ordertoplace)); Repo.SaveChanges(); Repo.removeFromRestonInv(doughtosubtract); Repo.SaveChanges(); return(RedirectToAction("Index", "")); } } return(View(ordertoplace)); }
// GET: Order/StartOrder public ActionResult StartOrder() { OrderWeb order = new OrderWeb(); return(View(order)); }