Пример #1
0
        private async void Save()
        {
            if (SelectedPayment.ChargedAccount == null)
            {
                ShowAccountRequiredMessage();
                return;
            }

            if (SelectedPayment.IsRecurring && !IsEndless && (EndDate.Date <= DateTime.Today))
            {
                ShowInvalidEndDateMessage();
                return;
            }

            // Make sure that the old amount is removed to not count the amount twice.
            RemoveOldAmount();
            SelectedPayment.Amount = amount;

            //Create a recurring payment based on the payment or update an existing
            await PrepareRecurringPayment();

            // Save item or update the payment and add the amount to the account
            var paymentSucceded = paymentManager.SavePayment(SelectedPayment);
            var accountSucceded = paymentManager.AddPaymentAmount(SelectedPayment);

            if (paymentSucceded && accountSucceded)
            {
                settingsManager.LastDatabaseUpdate = DateTime.Now;
            }

            Close(this);
        }
Пример #2
0
        /// <summary>
        ///     Checks if one of the recurring payment has to be repeated
        /// </summary>
        public void CheckRecurringPayments()
        {
            var paymentList = paymentManager.LoadRecurringPaymentList();

            foreach (var payment in paymentList.Where(x => x.ChargedAccount != null))
            {
                var relatedPayment = GetLastOccurence(payment);

                if (RecurringPaymentHelper.CheckIfRepeatable(payment.RecurringPayment, relatedPayment))
                {
                    var newPayment = RecurringPaymentHelper.GetPaymentFromRecurring(payment.RecurringPayment);

                    var paymentSucceded = paymentRepository.Save(newPayment);
                    var accountSucceded = paymentManager.AddPaymentAmount(newPayment);
                    if (paymentSucceded && accountSucceded)
                    {
                        settingsManager.LastDatabaseUpdate = DateTime.Now;
                    }
                }
            }
        }
Пример #3
0
        private async void Save()
        {
            if (SelectedPayment.ChargedAccount == null)
            {
                ShowAccountRequiredMessage();
                return;
            }

            if (SelectedPayment.IsRecurring && !IsEndless && (EndDate.Date <= DateTime.Today))
            {
                ShowInvalidEndDateMessage();
                return;
            }

            // Make sure that the old amount is removed to not count the amount twice.
            RemoveOldAmount();
            if (amount < 0)
            {
                amount *= -1;
            }
            SelectedPayment.Amount = amount;

            //Create a recurring PaymentViewModel based on the PaymentViewModel or update an existing
            await PrepareRecurringPayment();

            // Save item or update the PaymentViewModel and add the amount to the AccountViewModel
            var paymentSucceded = paymentManager.SavePayment(SelectedPayment);
            var accountSucceded = paymentManager.AddPaymentAmount(SelectedPayment);

            if (paymentSucceded && accountSucceded)
            {
                settingsManager.LastDatabaseUpdate = DateTime.Now;

#pragma warning disable 4014
                backupManager.EnqueueBackupTask();
#pragma warning restore 4014
            }

            Close(this);
        }