Esempio n. 1
0
        private void Calculate(int startIndex, int lastIndex, decimal percentage, decimal monthPayment, CreditDTO credit, Credit entity, List <MonthPayment> payments)
        {
            for (var i = startIndex; i < lastIndex; i++)
            {
                var percentegePayment = credit.Amount * percentage / 100 / 12;
                var payment           = new MonthPayment
                {
                    Number     = i,
                    Persentege = percentage,
                    Credit     = entity
                };

                payment.Payment = percentegePayment + monthPayment;

                if (credit.Amount - monthPayment < 0)
                {
                    monthPayment = credit.Amount;
                }

                credit.Amount -= monthPayment;

                payment.PersentegesPyment = percentegePayment;
                payments.Add(payment);
            }
        }
 public MonthPaymentDTO Delete(MonthPaymentDTO obj)
 {
     try
     {
         MonthPayment payment = _mapper.Map <MonthPayment>(obj);
         monthPaymentRepository.Delete(payment);
         return(obj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public MonthPaymentDTO AddOrUpdate(MonthPaymentDTO obj)
 {
     try
     {
         MonthPayment payment = _mapper.Map <MonthPayment>(obj);
         monthPaymentRepository.AddOrUpdate(payment);
         return(_mapper.Map <MonthPaymentDTO>(payment));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }