public ActionResult LogOn(UserLogOn user) { if (ModelState.IsValid) { try { using (var db = new HotelDbContext()) { var v = db.Customers.FirstOrDefault( userCheck => userCheck.Username.Equals(user.Username) && userCheck.Password.Equals(user.Password)); if (v != null) { FormsAuthentication.SetAuthCookie(user.Username, false); return RedirectToAction("Reserve", "CustomerReservation", new { area = "Customer" }); } else { Response.Write("<div id='logmess'>"); Response.Write("Sorry,Invalid Username and Password Combination!!.Your Username or Password or Both incorrect.If you have no account Signup first"); Response.Write("</div>"); } } } catch (Exception exmException) { Response.Write("<div id='logmess'>"); Response.Write(exmException.Message); Response.Write("</div>"); } } return View(); }
public ActionResult LogOn(Models.Admin admin) { if (ModelState.IsValid) { using (var db = new HotelDbContext()) { var u = db.Admins.FirstOrDefault( adminCheck => adminCheck.Email == admin.Email && adminCheck.Password == admin.Password); if (u != null) { FormsAuthentication.SetAuthCookie(admin.Email, false); return RedirectToAction("ReservationInfoList", "ReservationDeatils", new { area = "Admin" }); } else { ModelState.AddModelError("", "Invalid Email and Password Combination!!"); } } } return View(); }