/// <summary>
 /// Add a user account to the repository.
 /// </summary>
 /// <param name="userAccount">UserAccount to add to the repository.</param>
 /// <returns></returns>
 public void AddUserAccount(UserAccount userAccount)
 {
     userAccount.Password = PasswordService.CreateHash(userAccount.Password);
     DBContext.UserAccounts.Add(userAccount);
     DBContext.SaveChanges();
 }
 public void AddUserAccount(UserAccount userAccount)
 {
     userAccount.Password = PasswordService.CreateHash(userAccount.Password);
     userAccount.Id = randomNumberGenerator.Next();
     UserAccounts.Add(userAccount.Id, userAccount);
 }
        /// <summary>
        /// Update a UserAccount in the repository that has the matching Id with modified property values.
        /// </summary>
        /// <param name="userAccount">UserAccoubt object that contains the modified property values to update with.</param>
        /// <returns></returns>
        public void UpdateUserAccount(UserAccount userAccount)
        {
            if(String.IsNullOrEmpty(userAccount.Password))
            {
                //assume password is not being changed, pull the current hash from the db
                var account = FindUserAccountById(userAccount.Id);
                userAccount.Password = account.Password;
            }
            else {
                //assume password is being changed
                userAccount.Password = PasswordService.CreateHash(userAccount.Password);
            }

            DBContext.UserAccounts.AddOrUpdate(userAccount);
            DBContext.SaveChanges();
        }
 public void UpdateUserAccount(UserAccount userAccount)
 {
     if (String.IsNullOrEmpty(userAccount.Password))
     {
         //assume password is not being changed, pull the current hash from the db
         var account = FindUserAccountById(userAccount.Id);
         userAccount.Password = account.Password;
     }
     else
     {
         //assume password is being changed
         userAccount.Password = PasswordService.CreateHash(userAccount.Password);
     }
     UserAccounts[userAccount.Id] = userAccount;
 }