예제 #1
0
        public async Task ChangeUserPasswordCommand_UserPasswordAndSaltChanged()
        {
            // Arrange
            const string        userName           = "******";
            Guid                userId             = Guid.NewGuid();
            const string        userPassword       = "******";
            const string        passwordSalt       = "SaltySalt";
            User                user               = new User(userId, userName, "Dirk", "Gently", "*****@*****.**", userPassword, passwordSalt, "555-1234");
            IAccountsRepository accountsRepository = _container.Resolve <IAccountsRepository>();
            await accountsRepository.Add(user);

            // Act
            ICommandBus  commandBus  = _container.Resolve <ICommandBus>();
            const string newPassword = "******";
            await commandBus.Send(new ChangeUserPasswordCommand
            {
                UserId   = userId,
                Password = newPassword
            });

            IAccountsPerspective        accountsPerspective = _container.Resolve <IAccountsPerspective>();
            AccountWithCredentialsModel userWithCredentials = await accountsPerspective.GetUserWithCredentials(userName);

            // Assert
            userWithCredentials.PasswordHash
            .Should().NotBeNullOrWhiteSpace("Password should be hashed and contained")
            .And.NotBe(userPassword)
            .And.NotBe(newPassword);

            userWithCredentials.PasswordSalt
            .Should().NotBeEmpty()
            .And.NotBe(passwordSalt);
        }
예제 #2
0
        private async void Initialize(ICategoriesRepository catsRepo, IAccountsRepository accsRepo)
        {
            await catsRepo.Add(new Category { Name = "Transfer" });

            await catsRepo.Add(new Category { Name = "Drinks" });

            await catsRepo.Add(new Category { Name = "Weed" });

            await catsRepo.Add(new Category { Name = "Junk food" });

            await catsRepo.Add(new Category { Name = "Salary" });

            await accsRepo.Add(new Account { Name = "Cash", Currency = "rub", IsCash = true });

            await accsRepo.Add(new Account { Name = "Credit card", Currency = "usd", IsCash = false });
        }
예제 #3
0
        private void ImportAccounts(string path)
        {
            var itemList = _excelService.GetItemsFromTemplate <Account>(path);

            foreach (var item in itemList)
            {
                _accountsRepository.Add(item);
            }
        }
예제 #4
0
        public int AddAccount(AccountBusiness accountBusiness)
        {
            var account = new Account()
            {
                Name     = accountBusiness.Name,
                Password = accountBusiness.Password,
                CoupleID = accountBusiness.CoupleID,
                Token    = accountBusiness.Token
            };

            return(_accountRepository.Add(account));
        }
예제 #5
0
        public async Task <Guid> CreateAccount(Guid userId, string currencyCharCode)
        {
            var accountId = Guid.NewGuid();
            await _accountsRepository.Add(new Account
            {
                Amount           = 0,
                Id               = accountId,
                UserId           = userId,
                CurrencyCharCode = currencyCharCode,
            });

            return(accountId);
        }
예제 #6
0
        /// <summary>
        /// 创建账户
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public async Task <Result> Create(Account account)
        {
            if (await _accountsRepository.GetEntity(f => f.TenancyId == account.TenancyId && (f.Username.Equals(account.Username) || f.Email.Equals(account.Email) || f.TelPhone.Equals(account.TelPhone))) != null)
            {
                return(Result.ReFailure(ResultCodes.AccountExist));
            }
            bool isAdd = await _accountsRepository.Add(account);

            if (!isAdd)
            {
                return(Result.ReFailure(ResultCodes.AccountCreate));
            }
            return(Result.ReSuccess());
        }
예제 #7
0
        private void SetCommands()
        {
            CreateButtonAction = new RelayCommand(async() => {
                var currency = (CurrencyText.ToLower() == "rub" || CurrencyText.ToLower() == "usd") ?
                               CurrencyText.ToLower() : "rub";

                await _accountsRepository.Add(new Account {
                    Name     = AccountNameText,
                    Balance  = double.Parse(BalanceText),
                    Currency = currency,
                    IsCash   = IsCash
                });

                _navigationService.GoBack();
            }, () => true);
        }
예제 #8
0
        public Account Create()
        {
            var result = new Account();

            _consoleHelper.WriteLine("Creating an account:");
            _consoleHelper.WriteLine("Account Id:");
            result.Id = int.Parse(_consoleHelper.ReadLine());
            _consoleHelper.WriteLine("Account Name:");
            result.Name = _consoleHelper.ReadLine();
            _consoleHelper.WriteLine("Account Number:");
            result.Number = _consoleHelper.ReadLine();
            _consoleHelper.WriteLine("Account Value:");
            result.Value = decimal.Parse(_consoleHelper.ReadLine());

            _accountsRepository.Add(result);

            return(result);
        }
예제 #9
0
        public IUserAccount Create(IUserAccount account)
        {
            List <KeyValuePair <string, string> > accountFailedValidations = account.Validate();

            if (accountFailedValidations.Any())
            {
                throw new ValidationFailedException(accountFailedValidations);
            }

            //Validate if email doesn't exist
            IPerson personWithEmail = _personsRepository.GetByEmail(account.Email);

            if (personWithEmail.Id != 0)
            {
                throw new EmailAlreadyInUseException($"Email '{account.Email}' is already in use");
            }

            IPerson personDb = new PersonDTO()
            {
                Email        = account.Email,
                PersonTypeId = (int)account.PersonType,
                Name         = account.Name,
                LastName     = account.LastName
            };

            _personsRepository.Add(personDb);
            _uow.Save();

            IPerson  savedPerson = _personsRepository.GetByEmail(account.Email);
            IAccount accountDb   = new AccountDTO()
            {
                IsActive           = true,
                AccountTypeId      = (int)account.AccountType,
                IdentityProviderId = account.IdentityProviderId,
                PersonId           = savedPerson.Id
            };

            _accountsRepository.Add(accountDb);
            _uow.Save();

            IAccountDetail createdAccount = _accountsRepository.GetByIdentityProviderId(account.IdentityProviderId);

            return(new UserAccount(createdAccount));
        }
 public async Task AddAccount(Account account)
 {
     await _accountsRepository.Add(account);
 }
 public async Task Handle(CreateAccountCommand command)
 {
     User user = new User(command.Id, command.LoginName, command.Name, command.Surname, command.Email, command.PasswordHash, command.PasswordSalt, command.TelephoneNumber);
     await _accountRepository.Add(user);
 }
예제 #12
0
        public JsonResult SaveAccount([CustomizeValidator] Accounts acc)
        {
            bool result = _accountsRepository.Add(acc);

            return(Json <string>("保存成功", result));
        }