public Task <UserMultiAccount> GetAsync(Guid id)
 {
     return(_context.Set <UserMultiAccount>()
            .Include(x => x.UserAccountData)
            .Include(x => x.MatrixPositions)
            .SingleOrDefaultAsync(x => x.Id == id));
 }
Exemplo n.º 2
0
 public Task <UserMultiAccount> GetRandomUserMultiAccountSponsor()
 {
     return(_context.Set <UserMultiAccount>()
            .Where(x => x.RefLink != null)
            .OrderBy(r => Guid.NewGuid())
            .Take(1)
            .FirstAsync());
 }
Exemplo n.º 3
0
 public Task <MatrixPosition> GetTopParentAsync(MatrixPosition matrixPosition, int matrixLevel = 0)
 {
     return(_context.Set <MatrixPosition>()
            .Where(x => x.Left < matrixPosition.Left)
            .Where(x => x.Right > matrixPosition.Right)
            .Where(x => x.DepthLevel == matrixPosition.DepthLevel - 2)
            .Where(x => x.MatrixLevel == matrixLevel)
            .SingleOrDefaultAsync());
 }
Exemplo n.º 4
0
        private async Task LeftRightValuesReindexation(MatrixPosition matrixPositionBought)
        {
            await _context.Set <MatrixPosition>()
            .Where(x => x.Left > matrixPositionBought.Left)
            .Where(x => x.MatrixLevel == matrixPositionBought.MatrixLevel)
            .UpdateAsync(x => new MatrixPosition
            {
                Left = x.Left + 4
            });

            await _context.Set <MatrixPosition>()
            .Where(x => x.Right >= matrixPositionBought.Right)
            .Where(x => x.MatrixLevel == matrixPositionBought.MatrixLevel)
            .UpdateAsync(x => new MatrixPosition
            {
                Right = x.Right + 4
            });
        }
        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);
        }
Exemplo n.º 6
0
        private async Task <bool> CheckIfAllMultiAccountsAreInMatrixPositions(IEnumerable <Guid> userMultiAccountIds)
        {
            // TODO: Move it to helper
            var allUserMultiAccountsInMatrixPositions = await _context.Set <MatrixPosition>()
                                                        .Where(x => userMultiAccountIds.Contains(x.UserMultiAccountId.Value))
                                                        .Select(x => x.UserMultiAccountId.Value)
                                                        .ToListAsync();

            return(allUserMultiAccountsInMatrixPositions.ContainsAll(userMultiAccountIds));
        }
Exemplo n.º 7
0
 public Task <List <UserAccountData> > GetAllAsync()
 {
     return(_context.Set <UserAccountData>()
            .Include(x => x.UserMultiAccounts)
            .ToListAsync());
 }
Exemplo n.º 8
0
 public Task <PaymentHistory> GetAsync(Guid paymentId)
 {
     return(_context.Set <PaymentHistory>().SingleAsync(x => x.PaymentId == paymentId));
 }
Exemplo n.º 9
0
 public Task <List <Ticket> > GetAllAsync()
 {
     return(_context.Set <Ticket>().ToListAsync());
 }
Exemplo n.º 10
0
 public Task <Article> GetAsync(Guid id)
 {
     return(_context.Set <Article>().SingleAsync(x => x.Id == id));
 }
Exemplo n.º 11
0
 public Task <Withdrawal> GetAsync(Guid id)
 {
     return(_context.Set <Withdrawal>().SingleAsync(x => x.Id == id));
 }
Exemplo n.º 12
0
 public Task <MatrixPosition> GetAsync(Guid id)
 {
     return(_context.Set <MatrixPosition>().SingleAsync(x => x.Id == id));
 }