public ActionResult Login(FormCollection form) { var formEmail = form["LoginEmail"]; var formPassword = form["LoginPassword"]; OrderModel model = new OrderModel(); using (var db = new MyDataContainer()) { bool ExistsinDatabase = db.Users.Where(item => item.Email == formEmail && item.Password == formPassword).Any(); if (ExistsinDatabase == true) { //var xas = db.Users.Where(pro => pro.Email == formEmail).ToList(); Users user = db.Users.Where(item => item.Email == formEmail).FirstOrDefault(); var room = db.Users.Where(i => i.Email == formEmail).Select(i => i.Room).First(); Session["Email"] = formEmail; Session["Room"] = room; return RedirectToAction("Index", "Start"); } else { ModelState.AddModelError("Username", "Invalid username and/or password"); } return View("Login"); } }
// // GET: /MakeRequest/ public ActionResult Index() { var model = new OrderModel { Room = Session["Room"].ToString(), Email = Session["Email"].ToString() }; return View(model); }
public ActionResult Checkout(FormCollection form) { OrderModel model = new OrderModel(); model.foodTitle = form["foodtitle"]; model.foodPrice = Convert.ToDouble(form["foodprice"]); using (var db = new MyDataContainer()) { var rowtoupdate = db.Order.Where(pro => pro.Ordered == "Unordered").ToList(); foreach (var item in rowtoupdate) { item.Ordered = form["Ordered"]; } db.SaveChanges(); return RedirectToAction("SendWelcomeMessage", model); } }