public ActionResult addRestaurant(restaurantViewModel formvalues) { if (TempData.ContainsKey("adminId")) { if (ModelState.IsValid) { try { restaurantViewModel restaurantView = new restaurantViewModel(); ViewBag.status = restaurantView.listOfStatus; restaurant restaurantTuple = formvalues.getRestaurantValues(); dbContext.restaurants.Add(restaurantTuple); dbContext.SaveChanges(); return(RedirectToAction("index")); } catch (Exception ex) { ViewBag.exception = ex.Message; } return(View()); } else { return(View()); } } else { TempData.Clear(); return(RedirectToAction("LogIn", "LogIn")); } }
// GET: Customer public ActionResult Index() { try { if (TempData.ContainsKey("custId")) { orderId = Convert.ToInt32(TempData.Peek("orderId")); restaurantViewModel restaurantView = new restaurantViewModel(); restaurantView.populateLocation(); ViewBag.locations = restaurantView.restaurantlocations; custId = TempData.Peek("custId") as string; ViewBag.tester = custId; return(View(dbContext.restaurants.ToList())); } else { custId = null; return(RedirectToAction("LogIn", "LogIn")); } } catch (Exception ex) { ViewBag.errorMessage = ex.Message; return(View(dbContext.restaurants.ToList())); } }
public ActionResult addRestaurant() { if (TempData.ContainsKey("adminId")) { restaurantViewModel restaurantView = new restaurantViewModel(); ViewBag.status = restaurantView.listOfStatus; return(View()); } else { TempData.Clear(); return(RedirectToAction("LogIn", "LogIn")); } }