public async Task <ActionResult <OrderDeliveryDto> > Post([FromBody] DeliveryRequestDto deliveryRequest)
        {
            var response = await _mediator.Send(new NewDeliveryRequest(deliveryRequest));

            if (response.Failed)
            {
                return(BadRequest());
            }

            return(CreatedAtAction(nameof(Get), new { deliveryId = response.Result.DeliveryId }, response.Result));
        }
        public async Task <ActionResult <OrderDeliveryDto> > Put([FromRoute] Guid deliveryId,
                                                                 [FromBody] DeliveryRequestDto deliveryRequest)
        {
            var response = await _mediator.Send(new UpdateDeliveryRequest(deliveryId, deliveryRequest));

            if (!response.Failed)
            {
                return(Ok(response.Result));
            }

            return(response.ErrorReason == OperationErrorReason.ResourceNotFound
                ? NotFound()
                : StatusCode(StatusCodes.Status500InternalServerError));
        }
Exemplo n.º 3
0
 public NewDeliveryRequest(DeliveryRequestDto deliveryRequestDto)
 {
     DeliveryRequestDto = deliveryRequestDto ?? throw new ArgumentNullException(nameof(deliveryRequestDto));
 }
 public UpdateDeliveryRequest(Guid deliveryId, DeliveryRequestDto deliveryRequestDto)
 {
     DeliveryId         = deliveryId;
     DeliveryRequestDto = deliveryRequestDto ?? throw new ArgumentNullException(nameof(deliveryRequestDto));
 }