Ejemplo n.º 1
0
        public ActionResult Authorize(User user)
        {
            if (user.Email == "*****@*****.**" && user.PasswordHash == "admin")
            {
                //admin recognition success
                Session["adminID"] = 1;//Id
                return(RedirectToAction("Index", "AdminPanel"));
            }

            var studentDetails = _studentBll.GetStudent(user);
            var teacherDetails = _teacherBll.GetTeacher(user);

            Session.Clear();

            if (studentDetails != null)
            {
                //student found
                Session["studentID"] = studentDetails.Id;
                return(RedirectToAction("Index", "Home"));
            }

            if (teacherDetails != null)
            {
                //teacher found
                Session["teacherID"] = teacherDetails.Id;
                return(RedirectToAction("Index", "Home"));
            }

            //user not found
            ViewData["Message"] = "Error";
            return(View("Index"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Contains more detailed information about the student.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>To student details View.</returns>
        public ActionResult StudentDetails(int id = 1)
        {
            //Can't access if you're not logged in
            if (Session["studentID"] == null && Session["teacherID"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            return(View(_studentBll.GetStudent(id)));
        }
        /// <summary>
        /// Checks session id for student.
        /// </summary>
        /// <returns>To student View or back up to check session.</returns>
        public ActionResult Student()
        {
            if (Session["studentID"] == null && Session["teacherId"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            if (Session["teacherId"] != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(_studentBll.GetStudent((int)Session["studentId"])));
        }