コード例 #1
0
        public void CanSerializeToTypedCommand_FromCommandConfig()
        {
            var json          = @"{'OriginalName': 'oude naam', 'Name': 'nieuwe naam'}";
            var projectsMoq   = new Mock <IProductService>();
            var commandConfig = new CommandConfig {
                Assembly = "SoftwareManagementCore", NameSpace = "ProductsShared", Name = "Rename", ProcessorName = "Product", Processor = projectsMoq.Object
            };
            RenameProductCommand command = commandConfig.GetCommand(json) as RenameProductCommand;

            Assert.Equal("oude naam", command.OriginalName);
        }
コード例 #2
0
        public async Task <IActionResult> Put(int productId, [FromBody] RenameProductModel renameProductModel, CancellationToken cancellationToken = default)
        {
            try
            {
                var productCommand = new RenameProductCommand(productId, renameProductModel.Name);
                await commandBus.Dispatch(productCommand, cancellationToken).ConfigureAwait(false);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }