public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new StudentDAO();
                var result = dao.Login(model.Email, Encryptor.MD5Hash(model.Password));
                if (result == 1)
                {
                    var student        = dao.GetById(model.Email);
                    var studentSession = new StudentLogin();
                    studentSession.Email = student.Email;
                    studentSession.ID    = student.Id;

                    Session.Add(Common_Constants.STUDENT_SESSION, studentSession);
                    return(RedirectToAction("Index", "Home"));
                }
                else if (result == 0)
                {
                    ModelState.AddModelError("", "Account is invalid");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", "Account was locked");
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", "Email or Password is incorrect");
                }
                else
                {
                    ModelState.AddModelError("", "Login false.");
                }
            }
            return(View("Index"));
        }
        public void Student_GetById()
        {
            StudentDAO dao             = new StudentDAO();
            Students   selectedStudent = dao.GetById(2);

            Assert.NotNull(selectedStudent);
        }
 //id=userId
 public StudentResponse GetById(Guid Id)
 {
     return(_studentDao.GetById(Id));
 }
示例#4
0
 public Student GetById(long id)
 {
     _studentDAO = new StudentDAO();
     return(_studentDAO.GetById(id));
 }