コード例 #1
0
 public ActionResult Login(TaiKhoan taiKhoan)
 {
     if (ModelState.IsValid)
     {
         TaiKhoan user = taiKhoanRepository.GetTaiKhoanByUserNameAndPassword(taiKhoan.UserName, taiKhoan.Password);
         if (user != null)
         {
             Session["TaiKhoanID_session"] = user.TaiKhoanID;
             if (user.Role == "admin")
             {
                 return(RedirectToAction("Index", "HomeAdmin", new { Area = "Admin" }));
             }
             else if (user.Role == "student")
             {
                 return(RedirectToAction("Index", "Home"));
             }
             else if (user.Role == "teacher")
             {
                 return(RedirectToAction("Index", "HomeTeacher", new { Area = "Teacher" }));
             }
         }
     }
     return(View());
 }