public ActionResult Index(LoginModel model) { if (ModelState.IsValid) { var dao = new StudentDao(); var result = dao.IsValid(model.username, Encryptor.MD5Hash(model.password)); if (result) { var admin = dao.GetByUserName(model.username); var studenSession = new StudentLogin(); studenSession.id_student = admin.id_student; studenSession.student_name = admin.student_name; studenSession.student_avatar = admin.student_avatar; Session.Add(CommonConstants.STUDENT_SESSION, studenSession); dao.UpdateLastLogin(studenSession.id_student, GetIPAddress(), GetUserEnvironment()); dao.UpdateLastSeen("Trang chủ", Url.Action("Index"), studenSession.id_student); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Sai thông tin đăng nhập."); } } return(View(model)); }