public async Task <Response> SavePaymentCalendarConfiguration(PaymentCalendarRequest paymentCalendarRequest)
        {
            var paymentConfigurationDuplicated = _securityPaymentContext.PaymentCalendar.ToList()
                                                 .Find(x => x.PaymentDate == paymentCalendarRequest.PaymentDate);

            if (paymentConfigurationDuplicated == null)
            {
                ControlTransactionFields transactionInfo = TransactionInfo.GetTransactionInfo();

                IDbContextTransaction transaction = _securityPaymentContext.Database.BeginTransaction();

                PaymentCalendar paymentCalendarConfiguration = MaterializePaymentConfiguration(paymentCalendarRequest, transactionInfo);

                await _securityPaymentContext.AddAsync <PaymentCalendar>(paymentCalendarConfiguration);

                await _securityPaymentContext.SaveChangesAsync();

                transaction.Commit();
                return(new Response {
                    Data = paymentCalendarConfiguration
                });
            }
            return(new Response {
                Message = "Failed, the payment configuration already exist!"
            });
        }
 private PaymentCalendar MaterializePaymentConfiguration(PaymentCalendarRequest paymentCalendarRequest, ControlTransactionFields transactionInfo)
 {
     return(new PaymentCalendar
     {
         PaymentDate = paymentCalendarRequest.PaymentDate,
         PaymentCalendarAmmount = paymentCalendarRequest.PaymentCalendarAmmount,
         TransactionDate = transactionInfo.TransactionDate,
         ComputerName = transactionInfo.ComputerName,
         UserTransaction = transactionInfo.UserTransaction
     });
 }
Esempio n. 3
0
        public async Task <IActionResult> SavePaymentCalendarConfiguration([FromBody] PaymentCalendarRequest paymentCalendarRequest)
        {
            var message = await _paymentCalendarService.SavePaymentCalendarConfiguration(paymentCalendarRequest);

            return(Ok(message));
        }