public ActionResult Create(CustomerWeb customer) { try { if (ModelState.IsValid) { Repo.AddCustomer(new CustomerWeb { firstName = customer.firstName, lastName = customer.lastName, userName = customer.userName, password = customer.password, favoriteLocationId = (int)customer.favoriteLocationId }); Repo.Save(); CustomerWeb customerInfo = Repo.GetCustomerByUsername(customer.userName); TempData["CustomerID"] = customerInfo.id; TempData["CustomerFirstName"] = customerInfo.firstName; TempData["CustomerLastName"] = customerInfo.lastName; TempData["CustomerFavoriteLocation"] = customerInfo.favoriteLocationId; TempData["CustomerAdmin"] = customerInfo.admin; } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
// GET: Customer/Details/5 public ActionResult Details(int id) { var customer = Repo.GetCustomerById(id); var webCust = new CustomerWeb { id = customer.id, firstName = customer.firstName, lastName = customer.lastName, userName = customer.userName, password = customer.password, favoriteLocationId = customer.favoriteLocationId, admin = customer.admin }; return(View(webCust)); }
// GET: Order/OrderHistory public ActionResult OrderHistory(string sortID) { var orderList = Repo.GetOrderHistoryByCustomerId((int)TempData.Peek("CustomerId")); IEnumerable <OrderWeb> orderHistory = new List <OrderWeb>(); switch (sortID) { case "PriceLow": orderHistory = orderList.OrderBy(x => x.Total); break; case "PriceHigh": orderHistory = orderList.OrderByDescending(x => x.Total); break; case "Oldest": orderHistory = orderList.OrderBy(x => x.Dt); break; case "Newest": orderHistory = orderList.OrderByDescending(x => x.Dt); break; default: orderHistory = orderList; break; } //save customer name CustomerWeb customer = Repo.GetCustomerById((int)TempData.Peek("CustomerId")); TempData["CustomerFirstName"] = customer.firstName; TempData["CustomerLastName"] = customer.lastName; //save location and pizza names TempData["LocationId1"] = "Reston"; TempData["LocationId1"] = "Ashburn"; TempData["LocationId1"] = "Sterling"; TempData["PizzaId1"] = "Cheese"; TempData["PizzaId2"] = "Pepperoni"; TempData["PizzaId3"] = "Meat Lovers"; TempData["PizzaId4"] = "Veggie"; TempData["PizzaId5"] = "Hawaiian"; TempData["PizzaId6"] = "Golden Sun"; return(View(orderHistory)); }
public ActionResult Login(CustomerWeb customer) { try { CustomerWeb customerInfo = Repo.Login(customer); TempData["CustomerID"] = customerInfo.id; TempData["CustomerFirstName"] = customerInfo.firstName; TempData["CustomerLastName"] = customerInfo.lastName; TempData["CustomerFavoriteLocation"] = customerInfo.favoriteLocationId; TempData["CustomerAdmin"] = customerInfo.admin; return(RedirectToAction("Index", "Home")); } catch { return(View()); } }
// GET: Customer/Create public ActionResult Create() { CustomerWeb customer = new CustomerWeb(); return(View(customer)); }