public ActionResult Login(Models.LoginModel login) //Used this as a guide: //http://www.dotnetlearners.com/blogs/view/124/Login-Page-Example-In-MVC-Using-Entity-Frame-Work.aspx { if (ModelState.IsValid) { var db = new TheaterDbEntities(); try { var user = (from userlist in db.Customers where userlist.Username == login.Username && userlist.Password == login.Password select new { userlist.Customer_ID, userlist.First_Name, userlist.Last_Name }).ToList(); if (user.FirstOrDefault() != null) { Session["Customer_ID"] = user.FirstOrDefault().Customer_ID; Session["Full_Name"] = user.FirstOrDefault().First_Name + " " + user.FirstOrDefault().Last_Name; return(Redirect("/Home/Index")); } ModelState.AddModelError("", "Invalid Login Credentials"); return(View(login)); } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View(login)); } } else { ModelState.AddModelError("", "Invalid Model State"); return(View(login)); } }
/// <summary> /// Instantiates a new listing controller with the specified database model /// </summary> public ListingController(TheaterDbEntities db) { _db = db; }
public OrdersController(TheaterDbEntities db) { _db = db; }
/// <summary> /// Instantiates a new purchase controller with the specified database model /// </summary> public PurchaseController(TheaterDbEntities db) { _db = db; }
/// <summary> /// Instantiates a new preview controller with the specified database model /// </summary> public PreviewController(TheaterDbEntities db) { _db = db; }