public bool ActiveEmialVerification(User userObj)
        {
            User dbEntry = context.Users.Find(userObj.ID);
            if (dbEntry != null)
            {
                dbEntry.FullName = userObj.FullName;
                dbEntry.Email = userObj.Email;
                dbEntry.Password = userObj.Password;
                dbEntry.UserType = userObj.UserType;
                dbEntry.PrimaryUser = userObj.PrimaryUser;
                dbEntry.ConfirmPassword = userObj.Password;
                dbEntry.EmailVerified =true;
                dbEntry.Status = userObj.Status;
                dbEntry.LastModifiedDate = DateTime.Now;
                context.SaveChanges();

                Account acc = context.Accounts.Where(a => a.ID == dbEntry.AccountID).FirstOrDefault();
                accRepository.ActivateTrialAccount(acc);

                return true;
            }
            return false;
        }
        public ActionResult ChangePassword(User userObj)
        {
            User LoggedInUserObj = (User)Session["user"];
            Account accountObj = (Account)Session["account"];

            //var userToEdit = CCUserRepository.Users.Where(u => u.ID == userObj.ID).FirstOrDefault();

            //var test = Encryption.DecryptStringAES(LoggedInUserObj.Password, rand);

            if (Encryption.DecryptStringAES(LoggedInUserObj.Password, rand) == userObj.CurrentPassword)
            {

                if (userObj.Password != userObj.ConfirmPassword)
                {
                    Session["NewUserInfo"] = "Make sure you enter the New Passwords in both places correctly";
                    return RedirectToAction("ChangePassword");
                }
                else {
                    LoggedInUserObj.Password = Encryption.EncryptStringAES(userObj.Password, rand);
                    LoggedInUserObj.isPasswordChange = true;
                    var user = userRepository.SaveUser(LoggedInUserObj);
                    Session["user"] = user;
                    Session["NewUserInfo"] = "User Password Changed Successfully";
                    return RedirectToAction("AccountOptions");
                }
            }
            else
            {
                Session["NewUserInfo"] = "Entered Current Password does not match Users Current Password";
                return RedirectToAction("ChangePassword");
            }
        }
 public ActionResult ResetPassword(ForgotPasswordModel viewModel)
 {
     if (ModelState.IsValid)
     {
         User user = new User();
         user = userRepository.Users.FirstOrDefault(aid => aid.AccountID == viewModel.AccountID);
         user.Password = Encryption.EncryptStringAES(viewModel.Password, rand);
         userRepository.SaveUser(user);
         //Encryption.EncryptStringAES(sgnv.User.Password, rand);
     }
     ViewBag.MessagePass = "******";
     return View();
 }
 public User SaveUser(User userObj)
 {
     if (userObj.ID == 0)
     {
         context.Users.Add(userObj);
         context.SaveChanges();
     }
     else
     {
         User dbEntry = context.Users.Find(userObj.ID);
         if (dbEntry != null)
         {
             dbEntry.FullName = userObj.FullName;
             dbEntry.Email = userObj.Email;
             dbEntry.Password = userObj.Password;
             //dbEntry.UserType = userObj.UserType;
             dbEntry.PrimaryUser = userObj.PrimaryUser;
             dbEntry.ConfirmPassword = userObj.Password;
             //dbEntry.GUID = userObj.GUID;
             dbEntry.Status = userObj.Status;
             dbEntry.LastModifiedDate = DateTime.Now;
             dbEntry.isPasswordChange = userObj.isPasswordChange;
             context.SaveChanges();
         }
     }
     return userObj;
 }