public ActionResult ChangePassword(string OldPassword, string ConfirmPassword, User user)
        {
            try
            {
                var us = Db.Users.Single(r => r.UserId == ID);
                if (OldPassword == us.Password)
                {
                    if (user.Password == ConfirmPassword)
                    {
                        TryUpdateModel(us);
                        Db.SaveChanges();
                        return View("ChangeSuccessful");
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else
                    throw new Exception();

            }
            catch
            {
                // ViewBag.message="The Passwords don't match or your old password is wrong. Please try again";

                return View();
            }
        }
        public ActionResult Login(User user)
        {
            try
            {
                var rev = Db.Users
                     .Single(r => r.UserId == user.UserId);
                if (rev.Password != user.Password)
                    throw new Exception();
               if (user.UserId == "Admin")
                   if (user.TypeOfUser != "Admin")
                   {
                       ViewBag.msg = "Incorrect Username or Password, Try again";
                       return View("Index");
                   }
                //if(user.TypeOfUser=="")
                //    if (rev.TypeOfUser != "Candidate")
                //    {
                //        ViewBag.msg = "Incorrect Username or Password, Try again";
                //        return View("Index");

                //    }

                if (user.TypeOfUser == "Admin")
                    return RedirectToAction("Index", "AdminVoter");
                else if (user.TypeOfUser == "Student")
                    return RedirectToAction("Profile", "VoterMain", new { ID = user.UserId });
                else
                    return RedirectToAction("Profile", "CandidateMain", new { ID = user.UserId });

            }
            catch
            {

                ViewBag.msg = "Incorrect Username or Password, Try again";
                return View("Index");
            }
        }