示例#1
0
        public async Task <ActionResult <GenericCommandResult> > Create(
            [FromBody] CreateCouponCommand command,
            [FromServices] CouponHandler handler
            )
        {
            var result = handler.Handle(command);

            return(Ok(result));
        }
        public async Task <ActionResult <GenericCommandResult> > UpdateStatus(
            [FromBody] UpdateOrderStatusCommand command,
            [FromServices] OrderHandler handler,
            [FromServices] CouponHandler couponHandler
            )
        {
            var result = (GenericCommandResult)handler.Handle(command);
            var order  = (Order)result.Data;

            if (result.Success && order.Status.Equals("mercadoria devolvida", StringComparison.OrdinalIgnoreCase))
            {
                couponHandler.Handle(new CreateExchangeCouponCommand(order.CustomerId, order.ExchangedMerchandise));
            }
            return(Ok(result));
        }