Example #1
0
 public InvoicePayments CreateNewPayment(NewInvoicePaymentDto paymentDto)
 {
     return(new InvoicePayments()
     {
         InvoiceNo = paymentDto.Id,
         Amount = paymentDto.Amount,
         CashierId = paymentDto.CashierId,
     });
 }
        public ActionResult <PaymentView> AddInvoicePayment(uint invoiceId, [FromBody] NewInvoicePaymentDto payment)
        {
            if (!ModelState.IsValid)
            {
                return(new InvalidInputResponse(ModelState));
            }

            var invoice = _invoiceQuery.GetInvoiceById(invoiceId);

            if (invoice == null)
            {
                return(StatusCode(404, $"Invoice with id: {invoiceId} Not Found"));
            }

            var paymentOject = _factory.CreateNewPayment(payment);

            var paymentSummary = _command.AddPayment(paymentOject);

            if (paymentSummary != null)
            {
                return(StatusCode(201, paymentOject));
            }
            return(StatusCode(500));
        }