public IActionResult Post([FromBody] PaymentRequest request)
        {
            Model.Pay pay = new Model.Pay()
            {
                Amount    = request.Amount,
                InvoiceId = request.InvoiceId,
                Date      = DateTime.Now
            };

            _service.AddPay(pay);


            //RABBITMQ

            var paymentCommand = new PaymentCreateCommand(
                transactionId: pay.TransactionId,
                invoiceId: pay.InvoiceId,
                amount: pay.Amount,
                date: pay.Date
                );

            _bus.SendCommand(paymentCommand);

            var transactionCommand = new TransactionCreateCommand(
                transactionId: pay.TransactionId,
                invoiceId: pay.InvoiceId,
                amount: pay.Amount,
                date: pay.Date
                );

            _bus.SendCommand(transactionCommand);


            return(Ok());
        }
示例#2
0
        public async Task <ActionResult <PaymentModel> > CreatePayment([FromBody] PaymentCreateCommand command)
        {
            try
            {
                //validate
                _logger.LogInformation($"Veeash command: {command}");
                var response = await _mediator.Send(command);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Poota que paril, vc Errrou! {ex.Message}");
                return(BadRequest(ex.Message));
            }
        }