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);
 }
Пример #2
0
 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);
        }
Пример #4
0
        public async Task Delete(string productId)
        {
            var @event = await CreateEvent <object>(
                productId, EventTypes.ProductDeleted, null);

            var productDeleted = ProductDeleted.Create(@event, productId);

            messageQueue.Publish(productDeleted);
        }
Пример #5
0
 void OnProductDeleted(ProductDeleted productDeleted)
 {
     lock (lock_)
     {
         if (CheckMessageSanity(productDeleted))
         {
             data.Remove(productDeleted.ProductId);
         }
     }
 }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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();
            }
        }
Пример #8
0
        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}");
        }
Пример #9
0
 private void Apply(ProductDeleted @event)
 {
     Status = ProductStatus.Deleted;
 }
        public async Task Handle(ProductDeleted @event)
        {
            await Task.Delay(1000);

            await Mediator.Send(@event);
        }
Пример #11
0
 public void Handle(ProductDeleted @event, CommerceInstance instance)
 {
     DeleteIndex(@event.ProductId);
 }
Пример #12
0
 public Task HandleAsync(ProductDeleted @event)
 {
     return(RemoveCacheAsync());
 }
Пример #13
0
 private void Delete(IPersistedEvent pe, ProductDeleted e)
 {
    
 }
Пример #14
0
 private void Delete(IPersistedEvent pe, ProductDeleted e)
 {
 }