public async Task <bool> Handle(MarkOrderStatusAsBakedCommand 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 bakedEvent = new CupcakeOrderBakedEvent(cmd.Order); await _mediator.Publish(bakedEvent); return(true); //send acknowledgement as "true"(command accepted) }
public async Task <IActionResult> UpdateOrderStageAsBakedAsync([FromBody] MarkOrderStatusAsBakedCommand cmd) { if (!ModelState.IsValid) { BadRequest(); } var bakedOrder = cmd.Order; Console.WriteLine("===============Bake===================="); Console.WriteLine($"POST => updating order#{bakedOrder.Id} as baked, moving this to decorate queue"); Console.WriteLine("----"); Console.WriteLine($"Id:{bakedOrder.Id},Flavour: {bakedOrder.Flavour},Quantity:{bakedOrder.Quantity}"); Console.WriteLine($"BakedBy:{bakedOrder.BakedBy}, BakedOn:{bakedOrder.BakedOn}"); Console.WriteLine("==================================="); //Send a command to update the order status as baked var isAccepted = await _mediator.Send(cmd); //"your order has been updated as baked , moved it to decorate queue." return(Ok()); }