public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { HttpCookie DentalOfficeIDCookie = Request.Cookies["DentalOfficeIDCookie"]; if (DentalOfficeIDCookie != null) { Int64.TryParse(DentalOfficeIDCookie.Value, out DentalOfficeID); } Patientm patm = Patientms.GetOne(DentalOfficeID, model.UserName, model.Password); if (patm == null) { ModelState.AddModelError("", "Login Failed, Please Try Again"); } else { Session["Patient"] = patm; Prefms.LoadPreferences(); return(RedirectToAction("EHRInformation", "Medical")); } } return(View()); }