public ActionResult Login(LoginVM model) { if (!ModelState.IsValid) { return(View(model)); } if (model.AccountType.ToString() == "Doctor") { DoctorRepository repo = new DoctorRepository(); AuthenticationManager.AuthenticateDoctor(model.Username, model.Password); } else { PatientRepository repo = new PatientRepository(); AuthenticationManager.AuthenticatePatient(model.Username, model.Password); } if (AuthenticationManager.LoggedDoctor == null && AuthenticationManager.LoggedPatient == null) { ModelState.AddModelError("AuthenticationFailed", "Authentication failed!"); } if (!ModelState.IsValid) { return(View(model)); } return(RedirectToAction("Index", "Home")); }