// Login a user to the system
        public ActionResult Login([ModelBinder(typeof(SuperUserBinder))] SuperUser user)
        {
            Session["tempUser"]    = null;
            ViewData["inputError"] = "";
            if (Request.Form["userName"] != "" && Request.Form["userPassword"] != "")
            {
                if (user == null)
                {
                    ViewData["inputError"] = "User does not exist.";
                    return(View("Login"));
                }

                if ((string)Request.Form["userPassword"] != user.password)
                {
                    ViewData["inputError"] = "Password is incorrect.";
                    return(View("Login"));
                }

                Session["tempUser"] = user;

                if (user.getType() == "RegularUser")
                {
                    Session["tempUserType"] = "regularUser";
                }

                else if (user.getType() == "Admin")
                {
                    Session["tempUserType"] = "adminUser";
                }

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View("Login"));
            }
        }
 //Action result for changing password
 public ActionResult changePassowrd()
 {
     su = Session["user"] as SuperUser;
     if (su.getType() == "RICK")
     {
         AdminDAL dal   = new AdminDAL();
         Admin    admin = (from p in dal.Admins where p.Username == su.Username select p).SingleOrDefault();
         admin.Password = Request.Form["password"].ToString();
         dal.SaveChanges();
     }
     else
     {
         UserDAL dal  = new UserDAL();
         User    user = (from p in dal.Users where p.Username == su.Username select p).SingleOrDefault();
         user.Password = Request.Form["password"].ToString();
         dal.SaveChanges();
     }
     message = "Password changed successfully!";
     return(RedirectToAction("userHomePage"));
 }
        //Action result for user or admin panel according to the session
        public ActionResult userHomePage()
        {
            su = Session["user"] as SuperUser;
            if (message != null)
            {
                ViewBag.message = getMessage();
            }
            ThreadDal t_dal = new ThreadDal();

            ViewBag.threads = t_dal.Threads.ToList <Thread>();
            if (su.getType() == "RICK")
            {
                List <User> users = new List <User>();
                UserDAL     dal   = new UserDAL();

                users          = dal.Users.ToList <User>();
                ViewBag.mortys = users;

                return(View("RickPage"));
            }
            return(View("MortyPage"));
        }