public void ChangePassword(int userId, string newPassword)
        {
            IValidatePasswords validator = new Over6CharsPasswordValidator();
            validator.ValidatePassword(newPassword);

            validator = new ContainsLettersAndNumberPasswordValidator();
            validator.ValidatePassword(newPassword);

            var repository = new UserRepository();
            var user = repository.Get(userId);

            Logger.WriteLine("Changing password");
            user.Password = newPassword;

            var emailNotifier = new EmailNotifier(new EmailTemplateStore());
            emailNotifier.Notify(user);
        }
        static void Main(string[] args)
        {
            //var originalPwdChanger = new BeforeDIPasswordChanger();
            //originalPwdChanger.ChangePassword(1, "administrator1");

            //	Register
            ObjectFactory.Initialize((i => i.AddRegistry<DemoRegistry>()));

            //	Entry Point
            var passwordChanger = ObjectFactory.GetInstance<PasswordChanger>();

            passwordChanger.ChangePassword(1, "Password1");

            var user = new UserRepository().Get(1);
            Console.WriteLine();
            Console.WriteLine("Result: Password changed to '{0}'", user.Password);

            Console.ReadLine();
        }
        public void ChangePassword(int userId, string newPassword)
        {
            Console.WriteLine("Validating Password is greater than 6 chars");
            if (newPassword.Length < 6)
                throw new Exception("Password not long enough. Password should be create than 6 chars.");

            Console.WriteLine("Validating Password contains the number 1");
            if (!newPassword.Contains("1"))
                throw new Exception("Password does not contain the number 1.");

            var repository = new UserRepository();
            var user = repository.Get(userId);

            Console.WriteLine("Changing password");
            user.Password = newPassword;

            var message = "Your password has changed! If this wasn't you, please notify support";

            SmtpServer.Send(user.Email, message);
        }