public ActionResult Login(UserProfile profile)
        {
            using (var context = new DVTManagementSystemContext())
            {
                try
                {
                    var    PasswordHashingmMethod = new PasswordHashing();
                    string HashedPassword         = PasswordHashingmMethod.HashInput(profile.PasswordHash);



                    var user = context.UserProfiles.Single(u => u.EmailAddress == profile.EmailAddress && u.PasswordHash == profile.PasswordHash && u.IsApproved == true);
                    if (user != null)
                    {
                        Session["FirstName"] = user.FirstName.ToString();
                        Session["LastName"]  = user.FirstName.ToString();
                        return(RedirectToAction("Dashboard", "Applicant"));
                    }
                }
                catch (System.Exception)
                {
                    ModelState.AddModelError(string.Empty, "Username or Password is incorrect");
                }
            }


            return(View());
        }
        public ActionResult Create([Bind(Include = "UserProfileId,FirstName,LastName,IdentityNumber,DateOfBirth,GenderTypeId,UserTypeId,PhoneNumber,EmailAddress,PasswordHash,DepartmentId,IsApproved")] UserProfile userProfile)
        {
            if (ModelState.IsValid)
            {
                var passwordHashing = new PasswordHashing();
                userProfile.PasswordHash = passwordHashing.HashInput(userProfile.PasswordHash);
                db.UserProfiles.Add(userProfile);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "DepartmentName", userProfile.DepartmentId);
            ViewBag.GenderTypeId = new SelectList(db.Genders, "GenderId", "GenderType", userProfile.GenderTypeId);
            ViewBag.UserTypeId   = new SelectList(db.UserTypes, "UserTypeId", "UserRole", userProfile.UserTypeId);
            return(View(userProfile));
        }