/// <inheritdoc /> public async Task <IEnumerable <RecurringPayment> > GetPaymentsToRecur() { var recurringPayments = recurringPaymentRepository .GetMany(x => x.IsEndless || x.EndDate >= DateTime.Now.Date) .Include(x => x.RelatedPayments) .Where(x => x.ChargedAccount != null) .ToList(); var payments = new List <Payment>(); foreach (var recurringPayment in recurringPayments) { // Delete Recurring Payments without assosciated payments. // This can be removed in later versions, since this will be based on old data. if (!recurringPayment.RelatedPayments.Any()) { recurringPaymentRepository.Delete(recurringPayment); continue; } payments.Add(new Payment( await paymentRepository.GetById( recurringPayment.RelatedPayments.OrderByDescending(y => y.Date).First().Id))); } return(payments .Where(RecurringPaymentHelper.CheckIfRepeatable) .Select(x => new RecurringPayment(x.Data.RecurringPayment)) .ToList()); }
/// <inheritdoc /> public IEnumerable <RecurringPayment> GetPaymentsToRecur() { return(recurringPaymentRepository.GetMany(x => x.IsEndless || x.EndDate >= DateTime.Now.Date) .Where(x => x.ChargedAccount != null) .Select( x => new Payment( x.RelatedPayments.OrderByDescending(y => y.Date).First())) .Where(RecurringPaymentHelper.CheckIfRepeatable) .Select(x => new RecurringPayment(x.Data.RecurringPayment)) .ToList()); }
/// <inheritdoc /> public async Task <IEnumerable <RecurringPayment> > GetPaymentsToRecur() { var recurringPayments = recurringPaymentRepository .GetMany(x => x.IsEndless || x.EndDate >= DateTime.Now.Date) .Include(x => x.RelatedPayments) .Where(x => x.ChargedAccount != null) .ToList(); var payments = new List <Payment>(); foreach (var recurringPayment in recurringPayments) { payments.Add(new Payment( await paymentRepository.GetById( recurringPayment.RelatedPayments.OrderByDescending(y => y.Date).First().Id))); } return(payments .Where(RecurringPaymentHelper.CheckIfRepeatable) .Select(x => new RecurringPayment(x.Data.RecurringPayment)) .ToList()); }