public void AddPayment(DepositPaymentModel paymentModel)
 {
     var deposit = depositRepository.GetDepositById(paymentModel.DepositId);
     if (paymentModel.Type == DepositPaymentType.Income)
     {
         deposit.Balance += paymentModel.Amount;
     }
     else if (paymentModel.Type == DepositPaymentType.Outcome)
     {
         deposit.Balance -= paymentModel.Amount;
     }
     if (deposit.Balance < 1)
     {
         deposit.Balance = 0;
     }
     depositRepository.UpdateDeposit(deposit);
     var date = dateService.GetCurrentDate();
     var payment = new DepositPayment
     {
         Amount = paymentModel.Amount,
         DepositId = paymentModel.DepositId,
         Type = (int) paymentModel.Type,
         Date = date
     };
     depositPaymentRepository.CreatePayment(payment);
 }
Ejemplo n.º 2
0
 public DepositPaymentModel(DepositPayment payment)
 {
     Id = payment.Id;
     DepositId = payment.DepositId;
     Type = (DepositPaymentType) payment.Type;
     Amount = payment.Amount;
     Date = payment.Date;
     if (payment.Deposit != null)
     {
         DepositModel = new DepositModel(payment.Deposit, takePayments: false);
     }
 }