public async Task CreatePaymentsUpToRecur() { List <RecurringPayment> recurringPayments = await recurringPaymentDbAccess.GetRecurringPaymentsAsync(); List <Payment> recPaymentsToCreate = recurringPayments .Where(x => x.RelatedPayments.Any()) .Where(x => RecurringPaymentHelper .CheckIfRepeatable(x.RelatedPayments .OrderByDescending(d => d.Date) .First())) .Select(x => new Payment( RecurringPaymentHelper.GetPaymentDateFromRecurring(x), x.Amount, x.Type, x.ChargedAccount, x.TargetAccount, x.Category, x.Note, x)) .ToList(); await recurringPaymentDbAccess.SaveNewPaymentsAsync(recPaymentsToCreate); }
public async Task CreatePaymentsUpToRecur() { var recurringPayments = await recurringPaymentDbAccess.GetRecurringPayments() .ConfigureAwait(true); await recurringPaymentDbAccess.SaveNewPayments(recurringPayments.Where(x => RecurringPaymentHelper .CheckIfRepeatable(x.RelatedPayments .OrderByDescending(d => d.Date) .First())) .Select(x => new Payment( RecurringPaymentHelper.GetPaymentDateFromRecurring(x), x.Amount, x.Type, x.ChargedAccount, x.TargetAccount, x.Category, x.Note, x)) .ToList()) .ConfigureAwait(true); }