private AccountStatement AddStatementToUpdate(IMyMentorRepository repository, AccountStatementDto missingAccountStatement, AccountStatementBuilder accountStatementBuilder)
        {
            var asCurrency = repository.FindAllCurrencies(missingAccountStatement.CurrencyId);
            var statement = missingAccountStatement;
            var transactionCode = repository.FindTransactionTypesById(statement.TransactionTypeId).TransactionCode;
            AccountStatementDto accountStatementDto = null;
            var user = Task.Run(() => repository.FindUserWithAdminData(statement.UserId)).Result;

            accountStatementDto = Task.Run(() => accountStatementBuilder.SetAccountStatement(user,
               statement.Credit,
               statement.Debit,
               transactionCode,
               statement.DueDate,
               asCurrency.Single(),
               validationToken: statement.ValidationToken)).Result;

            //UserAdminData adminData;
            //using (var t = Task.Run(() => user.GetPointerObject<UserAdminData>("adminData")))
            //{
            //    adminData = t.Result;
            //}
            //adminData.Balance = accountStatementDto.Balance;
            //adminData.SaveAsync();
            return accountStatementDto.ConvertToAccountStatementDomain();
        }
        //public async Task FixRecords()
        //{
        //    var results =
        //        (await new ParseQuery<AccountStatement>().WhereEqualTo("currency", ParseObject.CreateWithoutData<Currency>("PrOfDBWHGg")).FindAsync()).ToArray();
        //    foreach (var result in results)
        //    {
        //        result["currency"] = ParseObject.CreateWithoutData<Currency>("K67StSNEYs");
        //        await result.SaveAsync();
        //    }            
        //}

        private void HandlePaymentRequiredRecovery(CreateCouponViewModel createCouponVm, EventDto eventsDto,
            IMyMentorRepository repository, CurrencyRetriver currencyRetriever, CurrencyDto currentCurrency)
        {
            if (createCouponVm.PaymentRequired && string.IsNullOrEmpty(createCouponVm.PaymentData))
            {
                var coupon = ParseObject.CreateWithoutData<Coupon>(createCouponVm.CouponId);
                coupon.CouponStatus = BL.Consts.CouponStatus.Pending;
                coupon.SaveAsync();
                UpdatePaymentNotRecieved(eventsDto, repository);
                return;
            }

            var accountStatementBuilder = new AccountStatementBuilder(repository, currencyRetriever)
            {
                CouponId = createCouponVm.CouponId,
                EventId = createCouponVm.EventId
            };

            var missingAccountStatements = GetMissingAccountStatements(createCouponVm, eventsDto);
            var accountStatementsByUser = missingAccountStatements.GroupBy(x=>x.UserId);
            var accountStatementsToUpdate = new List<AccountStatement>();
            foreach (var accountStatementByUser in accountStatementsByUser)
            {
                var user = Task.Run(() =>
                {
                    var userId = accountStatementByUser.Key;
                    return repository.FindUserWithAdminData(userId);
                }).Result;

                foreach (var accountStatement in accountStatementByUser)
                {
                    var transactionCode = repository.FindTransactionTypesById(accountStatement.TransactionTypeId).TransactionCode;
                    var asCurrency = repository.FindAllCurrencies(accountStatement.CurrencyId);
                    var accountStatementDto = Task.Run(() => accountStatementBuilder.SetAccountStatement(user,
                           accountStatement.Credit,
                           accountStatement.Debit,
                           transactionCode,
                           accountStatement.DueDate,
                           asCurrency.Single(),
                           validationToken: accountStatement.ValidationToken)).Result;
                    accountStatementDto.Order = accountStatement.Order;
                    accountStatementsToUpdate.Add(accountStatementDto.ConvertToAccountStatementDomain());
                }
            }            

            UpdateCouponAccountStatementsAndEvent(createCouponVm, repository, accountStatementsToUpdate, eventsDto);
        }