public async Task Handle(JObject jObject, ILog log, CancellationToken cancellationToken) { try { log.Info("Consume ProductCategoryUpdatedEvent"); var dataConsomed = jObject.ToObject <ProductCategoryUpdatedEvent>(); var data = await _productCategoryQueries.GetData(dataConsomed.Id); if (data != null) { data = _mapper.Map <ProductCategory>(dataConsomed); log.Info("Update ProductCategory"); //Consume data to Read Db _productCategoryRepository.Update(data); await _uow.CommitAsync(); } } catch (Exception ex) { log.Error("Error Updating data ProductCategory", ex); throw ex; } }
public async Task <IActionResult> Get(Guid id) { try { var data = await _productCategoryQueries.GetData(id); return(Ok(new ApiOkResponse(data, data != null ? 1 : 0))); } catch (Exception ex) { _logger.LogCritical(ex, $"Error on Get Customer [{id}]"); return(BadRequest(new ApiBadRequestResponse(500, "Something Wrong"))); } }
public async Task Handle(JObject jObject, ILog log, CancellationToken cancellationToken) { try { log.Info("Consume DeletedEvent"); var dataConsomed = jObject.ToObject <ProductCategoryDeletedEvent>(); var data = await _productCategoryQueries.GetData(dataConsomed.ProductCategoryId); log.Info("Delete Customer"); //Consume data to Read Db _productCategoryRepository.Delete(data); await _uow.CommitAsync(); } catch (Exception ex) { log.Error("Error Deleteing data customer", ex); throw ex; } }