public async Task Handle( ProductDeleted notification, CancellationToken cancellationToken) { _logger.LogInformation($"We publish the message {nameof(notification)}: {JsonSerializer.Serialize(notification)}"); await _daprClient.PublishEventAsync("product-deleted", notification); }
private void Apply(ProductDeleted @event) { if (Products.Contains(@event.ProductId)) { Products.Remove(@event.ProductId); } }
public void RemoveProduct(Guid productId) { var e = new ProductDeleted(productId); Apply(e); AddEvent(e); }
public async Task Delete(string productId) { var @event = await CreateEvent <object>( productId, EventTypes.ProductDeleted, null); var productDeleted = ProductDeleted.Create(@event, productId); messageQueue.Publish(productDeleted); }
void OnProductDeleted(ProductDeleted productDeleted) { lock (lock_) { if (CheckMessageSanity(productDeleted)) { data.Remove(productDeleted.ProductId); } } }
public void Handle(ProductDeleted @event, CommerceInstance instance) { var languageStore = GetLanguageStoreByInstance(instance.Name); var translationStore = GetTranlsationStoreByInstance(instance.Name); var key = new EntityKey(typeof(Product), @event.ProductId); foreach (var lang in languageStore.All()) { translationStore.Delete(CultureInfo.GetCultureInfo(lang.Name), key); } }
private void Process(ProductDeleted productDeleted) { using (_unitOfWork) { var productReviews = _productReviewRepository.GetByProductId(productDeleted.ProductId); foreach (var productReview in productReviews) { productReview.Delete(); _productReviewRepository.Update(productReview); } _unitOfWork.Commit(); } }
IMessage <object> ConstructMessage <T>(Event @event) { var data = @event.Data; if (data == null) { throw new ArgumentNullException(nameof(@event.Data)); } switch (data.Type) { case EventTypes.AmountUpdated: var amount = data.Payload as int?; if (amount != null) { return((IMessage <object>)AmountUpdated.Create(@event, data.Id, amount.Value)); } break; case EventTypes.ProductCreated: if (data.Payload is Product product) { return((IMessage <object>)ProductCreated.Create(@event, product)); } break; case EventTypes.ProductDeleted: return((IMessage <object>)ProductDeleted.Create(@event, data.Id)); case EventTypes.TitleUpdated: var title = data.Payload as string; return((IMessage <object>)TitleUpdated.Create(@event, data.Id, title)); default: break; } throw new ArgumentException($"InvalidEvent data: {data.Id}, " + $"{data.Type}, {data.Payload}"); }
private void Apply(ProductDeleted @event) { Status = ProductStatus.Deleted; }
public async Task Handle(ProductDeleted @event) { await Task.Delay(1000); await Mediator.Send(@event); }
public void Handle(ProductDeleted @event, CommerceInstance instance) { DeleteIndex(@event.ProductId); }
public Task HandleAsync(ProductDeleted @event) { return(RemoveCacheAsync()); }
private void Delete(IPersistedEvent pe, ProductDeleted e) { }