public ActionResult Admin(LoginInfo employee) { try { List <LoginInfo> status = loginManager.AdminLogin(employee); if (status.Count != 0) { if (status.Count() > 0) { var name = status[0].EmployeeName; Session["Admin"] = "Admin"; Session["User1"] = name; Session["user"] = status[0].Id; Session["status"] = true; if (status[0].UserTypeId == 1) { return(RedirectToAction("../Admin/Index")); } } } else { ViewBag.Msg = "User name or passwoer mismatch!"; } } catch (Exception exception) { ViewBag.Msg = exception.Message; } return(View()); }
public ActionResult Index(Login aLogin) { Session["UserType"] = aLogin.UserType; if (aLogin.UserType == "Admin") { List <Login> status = aLoginManager.AdminLogin(aLogin); if (status.Count() > 0) { var name = status[0].Name; Session["Id"] = status[0].Id; Session["user"] = name; Session["status"] = true; return(RedirectToAction("Index", "Admin")); } else { ViewBag.message = "Username and password in invalid"; } } else if (aLogin.UserType == "Doctor") { List <Login> status = aLoginManager.DoctorLogin(aLogin); if (status.Count() > 0) { var name = status[0].Name; Session["Id"] = status[0].Id; Session["user"] = name; Session["status"] = true; return(RedirectToAction("Index", "Doctor")); } else { ViewBag.message = "Username and password in invalid"; } } else { List <Login> status = aLoginManager.PatientLogin(aLogin); if (status.Count() > 0) { var name = status[0].Name; Session["Id"] = status[0].Id; Session["user"] = name; Session["status"] = true; return(RedirectToAction("Index", "Patient")); } else { ViewBag.message = "Username and password in invalid"; } } return(View()); }