Exemple #1
0
        public async Task <IActionResult> Update(Guid id, UpdateCatalogItemCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            return(Ok(await Mediator.Send(command)));
        }
        /// <summary>
        ///  Integration event handler which starts the Catalog Item create proccess
        /// </summary>
        /// <param name="eventMsg">
        ///  Integration event message which is sent by the WebMvc once Catalog Item is successfully created from the ui and validated from the WebMvc.
        /// </param>
        /// <returns></returns>
        public async Task Handle(CatalogItemUpdateIntegrationEvent eventMsg)
        {
            if (eventMsg.RequestId != Guid.Empty)
            {
                var updateCatalogItemCommand = new UpdateCatalogItemCommand(eventMsg.Id, eventMsg.Name, eventMsg.Price, eventMsg.Color);

                var requestUpdateCatalogItem = new IdentifiedCommand <UpdateCatalogItemCommand, CatalogItem>(updateCatalogItemCommand, eventMsg.RequestId);

                var result = await _mediator.Send(requestUpdateCatalogItem);
            }

            _logger.CreateLogger(nameof(CatalogItemUpdateIntegrationEventHandler))
            .LogTrace(false ? $"CatalogItemUpdate integration event has been received and a create new order process is started with requestId: {eventMsg.RequestId}" :
                      $"CatalogItemUpdate integration event has been received but a new order process has failed with requestId: {eventMsg.RequestId}");
        }
 public async Task <IActionResult> UpdateCatalogItemAsync(int id, UpdateCatalogItemCommand command)
 {
     Throw.Exception.IfNotEqual <int>(id, command.Id, "CatalogItemId");
     return(Ok(await _mediator.Send(command)));
 }
Exemple #4
0
        public async Task <IActionResult> UpdateCatalogItem(UpdateCatalogItemCommand command)
        {
            await _mediator.Send(command);

            return(Ok());
        }