/// <summary>
        /// Creates the user to the database
        /// </summary>
        /// <param name="viewModel">The form of the model that was used</param>
        /// <returns>True if successful save, false if not.</returns>
        public bool Create(AccountViewModel viewModel)
        {
            if (viewModel != null)
            {
                ApplyChanges(viewModel);

                // Verify we can create the user
                Model.Salt       = HashManager.GetSalt();
                Model.Password   = HashManager.HashPassword(viewModel.Password, Model.Salt);
                Model.CreatedOn  = DateTime.Now;
                Model.InviteCode = Codes.GenerateInviteCode();

                bool usernameExists = services.Account.AccountEmailExists(viewModel.Username);
                bool emailExists    = services.Account.AccountEmailExists(viewModel.Email);
                bool passwordsMatch = viewModel.Password == viewModel.PasswordVerify;


                if (!usernameExists && !emailExists && passwordsMatch)
                {
                    services.Account.AddAccount(Model);
                    return(services.Save());
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
        public void HashManager_HashPassword_HashesPassword()
        {
            String pass = "******";
            String salt = HashManager.GetSalt();
            String hash = HashManager.HashPassword(pass, salt);

            Assert.IsNotNull(hash);
        }
        public void HashManager_ValidatePassword_Returns_True()
        {
            String pass = "******";
            String salt = HashManager.GetSalt();
            String hash = HashManager.HashPassword(pass, salt);

            bool isPass = HashManager.ValidatePassword(pass, hash);

            Assert.AreEqual(true, isPass);
        }
        public void HashManager_GetSalt_Returns_Salt()
        {
            String salt = HashManager.GetSalt();

            Assert.IsNotNull(salt);
        }