Esempio n. 1
0
        public async Task <bool> Handle(MarkOrderStatusAsPackagedCommand cmd, CancellationToken cancellationToken)
        {
            //TODO::Verify if there is any order request with the input order
            // If no, reject command

            //Create required events for this action and publish them
            var boxedEvent = new CupcakeOrderPackagedEvent(cmd.Order);
            await _mediator.Publish(boxedEvent);

            return(true); //send acknowledgement as "true"(command accepted)
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateOrderStageAsPackagedAsync([FromBody] MarkOrderStatusAsPackagedCommand cmd)
        {
            if (!ModelState.IsValid)
            {
                BadRequest();
            }

            var boxedOrder = cmd.Order;

            Console.WriteLine("===============Packaging====================");
            Console.WriteLine($"POST => updating order#{boxedOrder.Id} as packaged , moving this to readytoship queue");
            Console.WriteLine("----");
            Console.WriteLine($"Id:{boxedOrder.Id},Flavour: {boxedOrder.Flavour},Quantity:{boxedOrder.Quantity}");
            Console.WriteLine($"PackagedBy:{boxedOrder.PackagedBy}, PackagedOn:{boxedOrder.PackagedOn}");
            Console.WriteLine("===================================");


            //Send a command to update the order status as boxed
            var isAccepted = await _mediator.Send(cmd);

            //"your order has been updated as packaged , moved it to readytoship queue."
            return(Ok());
        }