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));
        }
Exemplo n.º 2
0
        // GET: Student/Home
        public ActionResult Index()
        {
            var session    = (StudentLogin)Session[CommonConstants.STUDENT_SESSION];
            var id_student = session.id_student;

            if (studentDao.getTesting(id_student) > 0)
            {
                return(RedirectToAction("DoingTest"));
            }

            studentDao.UpdateLastLogin(id_student, GetIPAddress(), GetUserEnvironment());
            studentDao.UpdateLastSeen("Trang chủ", Url.Action("Index"), id_student);
            ViewBag.score      = studentDao.GetStudentTestcode(id_student);
            ViewBag.studenname = studentDao.ViewDetail(id_student).student_name;
            return(View(studentDao.GetDashboard()));
        }