コード例 #1
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));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Delete(int productId, CancellationToken cancellationToken = default)
        {
            try
            {
                var productCommand = new DeleteProductCommand(productId);
                await commandBus.Dispatch(productCommand, cancellationToken).ConfigureAwait(false);

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