private async Task PreValidation()
        {
            if (_multiAccount is null)
            {
                throw new ValidationException("User with given ID was not found.");
            }

            _userMatrixPositionOnLowerMatrix = await _matrixPositionHelper.GetPositionForAccountAtLevelAsync(_multiAccount.Id, _lowerLevelMatrix);

            if (_userMatrixPositionOnLowerMatrix is null)
            {
                throw new ValidationException($"User does not have position in the lower level matrix: {_lowerLevelMatrix}.");
            }

            var alreadyUpgraded = await _matrixPositionHelper.GetPositionForAccountAtLevelAsync(_multiAccount.Id, _command.MatrixLevel);

            if (alreadyUpgraded != null)
            {
                throw new ValidationException("User has already been upgraded to this level.");
            }

            if (await _paymentHistoryHelper.DoesUserPaidForMatrixLevelAsync(_command.MatrixLevel, _multiAccount.Id) == false)
            {
                throw new ValidationException("User didn't pay for the upgraded structure yet.");
            }
        }
Beispiel #2
0
        private async Task ValidateUserMultiAccount(UserMultiAccount userMultiAccount, int matrixLevel)
        {
            if (userMultiAccount is null)
            {
                throw new ArgumentNullException(nameof(userMultiAccount));
            }
            if (userMultiAccount.MatrixPositions.Any())
            {
                throw new ValidationException("This account already exists in a structure");
            }

            if (userMultiAccount.UserAccountData.IsMembershipFeePaid == false)
            {
                throw new ValidationException("The main account did not buy pay the membership's fee yet");
            }

            if (await _paymentHistoryHelper.DoesUserPaidForMatrixLevelAsync(matrixLevel, userMultiAccount.Id) == false)
            {
                throw new ValidationException($"User didn't pay for the structure at level {matrixLevel} yet");
            }

            if (!userMultiAccount.SponsorId.HasValue)
            {
                throw new ValidationException("This account does not have inviting multi account set");
            }
        }