Exemple #1
0
        private async Task AddTwoEmptyChildToBoughtPosition(MatrixPosition matrixPositionBought)
        {
            var newDepthLevel = matrixPositionBought.DepthLevel + 1;

            var matricesToAdd = new List <MatrixPosition>()
            {
                new MatrixPosition
                (
                    id: Guid.NewGuid(),
                    matrixLevel: matrixPositionBought.MatrixLevel,
                    depthLevel: newDepthLevel,
                    left: matrixPositionBought.Left + 1,
                    right: matrixPositionBought.Left + 2,
                    parentId: matrixPositionBought.Id,
                    userMultiAccountId: null
                ),
                new MatrixPosition
                (
                    id: Guid.NewGuid(),
                    matrixLevel: matrixPositionBought.MatrixLevel,
                    depthLevel: newDepthLevel,
                    left: matrixPositionBought.Left + 3,
                    right: matrixPositionBought.Left + 4,
                    parentId: matrixPositionBought.Id,
                    userMultiAccountId: null
                )
            };

            _context.Set <MatrixPosition>().AddRange(matricesToAdd);
            await _context.SaveChangesAsync();
        }
Exemple #2
0
        public async Task ClearDatabase()
        {
            var matrices         = _context.MatrixPositions;
            var multiAccounts    = _context.UserMultiAccounts;
            var users            = _context.UserAccountsData;
            var paymentHistories = _context.PaymentHistories;
            var articles         = _context.Articles;

            _context.MatrixPositions.RemoveRange(matrices);
            _context.UserMultiAccounts.RemoveRange(multiAccounts);
            _context.UserAccountsData.RemoveRange(users);
            _context.PaymentHistories.RemoveRange(paymentHistories);
            _context.Articles.RemoveRange(articles);

            await _context.SaveChangesAsync();
        }
        public async Task <Guid> Handle(RegisterNewUserAccountCommand command, CancellationToken cancellationToken = default(CancellationToken))
        {
            await ValidateForUniqueness(command);

            var sponsorId = await GetSponsorId(command);

            var hashSalt = PasswordEncryptionUtilities.GenerateSaltedHash(command.Password);

            var userAccountData = new UserAccountData
                                  (
                id: Guid.NewGuid(),
                email: command.Email,
                login: command.Login,
                firstName: command.FirstName,
                lastName: command.LastName,
                street: command.Street,
                city: command.City,
                zipCode: command.ZipCode,
                country: command.Country,
                btcWalletAddress: command.BtcWalletAddress,
                role: UserRolesHelper.User
                                  );

            userAccountData.SetPassword(hashSalt.Salt, hashSalt.Hash);

            await _context.Set <UserAccountData>().AddAsync(userAccountData);

            await _context.SaveChangesAsync();

            // TODO: Event that user was created: eventhandler should create new multiaccount for him
            var userMultiAccount = new UserMultiAccount
                                   (
                id: Guid.NewGuid(),
                userAccountDataId: userAccountData.Id,
                sponsorId: sponsorId,
                multiAccountName: userAccountData.Login
                                   );

            userMultiAccount.SetAsMainAccount();

            await _userMultiAccountRepository.CreateAsync(userMultiAccount);

            return(userAccountData.Id);
        }
 public Task CreateAsync(UserMultiAccount userMultiAccount)
 {
     _context.Set <UserMultiAccount>().Add(userMultiAccount);
     return(_context.SaveChangesAsync());
 }
 public Task UpdateAsync(UserAccountData userAccountData)
 {
     _context.Set <UserAccountData>().Attach(userAccountData);
     return(_context.SaveChangesAsync());
 }
 public Task CreateAsync(PaymentHistory paymentHistory)
 {
     _context.Set <PaymentHistory>().Add(paymentHistory);
     return(_context.SaveChangesAsync());
 }
Exemple #7
0
 public Task CreateAsync(Ticket ticket)
 {
     _context.Set <Ticket>().Add(ticket);
     return(_context.SaveChangesAsync());
 }
Exemple #8
0
 public Task CreateAsync(Article article)
 {
     _context.Set <Article>().Add(article);
     return(_context.SaveChangesAsync());
 }
 public Task CreateAsync(Withdrawal withdrawal)
 {
     _context.Set <Withdrawal>().Add(withdrawal);
     return(_context.SaveChangesAsync());
 }
Exemple #10
0
 public Task UpdateAsync(MatrixPosition matrixPosition)
 {
     _context.Set <MatrixPosition>().Attach(matrixPosition);
     return(_context.SaveChangesAsync());
 }