private static void RegenerateActivationKey(string email)
 {
     using (var db = new FortyLifeDbContext())
     {
         var user = db.ApplicationUsers.FirstOrDefault(i => i.Email == email);
         if (user != null)
         {
             user.ActivationKey = RemoveReservedUnsafeCharacters(UserAuthenticator.GetHashString(DateTime.Now.ToString("G")));
             db.SaveChanges();
         }
     }
 }
        public static bool CreateAccount(string email, string password)
        {
            if (GetApplicationUser(email) != null)
            {
                return(false);
            }

            var salt         = UserAuthenticator.GetHashString(DateTime.Now.Ticks.ToString());
            var passwordHash = UserAuthenticator.ComputeHash(password, salt);

            var newUser = new ApplicationUser
            {
                Email         = email,
                DisplayName   = email.Split('@')[0],
                PasswordHash  = passwordHash,
                PasswordSalt  = salt,
                CreateDate    = DateTime.Now,
                ActivationKey = RemoveReservedUnsafeCharacters(UserAuthenticator.GetHashString(DateTime.Now.ToString("G")))
            };

            using (var db = new FortyLifeDbContext())
            {
                try
                {
                    db.ApplicationUsers.AddOrUpdate(newUser);
                    db.SaveChanges();

                    SendActivationEmail(email);

                    return(true);
                }
                catch (Exception e)
                {
                    // TODO: implement proper logger for exceptions
                    return(false);
                }
            }
        }