Exemplo n.º 1
0
        public async Task <ActionResult <DeliveryRequestDto> > CreateDeliveryRequest(CreateDeliveryRequestDto model)
        {
            var deliveryRequest = await _deliveryService.CreateDeliveryRequestAsync(model);

            if (deliveryRequest != null)
            {
                return(Created(string.Empty, deliveryRequest));
            }
            return(UnprocessableEntity());
        }
Exemplo n.º 2
0
        public async Task Consume(ConsumeContext <IDeliveryRequest> context)
        {
            _logger.LogInformation($"Delivery Request called for order {context.Message.OrderId}");

            try
            {
                await _deliveryService.CreateDeliveryRequestAsync(new CreateDeliveryRequestDto
                {
                    OrderId         = context.Message.OrderId,
                    DeliveryAddress = context.Message.DeliveryAddress,
                    DeliveryDate    = context.Message.DeliveryDate,
                    Recipient       = context.Message.Recipient
                });

                await context.RespondAsync <IDeliveryRequestResult>(new { Success = true });
            }
            catch (Exception)
            {
                await context.RespondAsync <IDeliveryRequestResult>(new { Success = false });
            }
        }