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)); } }
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)); } }