Ejemplo n.º 1
0
        public override void Delete(int id)
        {
            PaymentDeleteModel data = this.bankAccountRepository.FindByCondition(b => b.Id == id)
                                      .Include(a => a.InterestRates)
                                      .Include(a => a.Payments)
                                      .ThenInclude(pt => pt.PaymentTags)
                                      .Select(b => new PaymentDeleteModel(b, b.InterestRates, b.Payments, b.Payments.SelectMany(a => a.PaymentTags)))
                                      .Single();

            foreach (PaymentTag paymentTag in data.paymentTags)
            {
                this.paymentTagRepository.Delete(paymentTag);
            }

            foreach (Payment payment in data.payments)
            {
                this.paymentRepository.Delete(payment);
            }

            foreach (InterestRate interest in data.interests)
            {
                this.interestRateRepository.Delete(interest);
            }

            this.bankAccountRepository.Delete(data.bankAccount);
            this.bankAccountRepository.Save();
        }
Ejemplo n.º 2
0
        public void DeleteBankAccount(int id)
        {
            PaymentDeleteModel data = this.bankAccountRepository.FindAll().Where(b => b.Id == id && b.UserIdentityId == this.GetLoggedUserId())
                                      .Include(a => a.InterestRates)
                                      .Include(a => a.Payments)
                                      .ThenInclude(pt => pt.PaymentTags)
                                      .Select(b => new PaymentDeleteModel(b, b.InterestRates, b.Payments, b.Payments.SelectMany(a => a.PaymentTags)))
                                      .Single();

            foreach (PaymentTag paymentTag in data.paymentTags)
            {
                this.paymentTagRepository.Delete(paymentTag);
            }

            foreach (Payment payment in data.payments)
            {
                this.paymentRepository.Delete(payment);
            }

            foreach (InterestRate interest in data.interests)
            {
                this.interestRateRepository.Delete(interest);
            }

            this.bankAccountRepository.Delete(data.bankAccount);
            this.bankAccountRepository.Save();
        }