public async Task Handle(ProductCreated @event, CancellationToken cancellationToken)
        {
            try
            {
                @event.Payload = JsonConvert.SerializeObject(new
                {
                    @event.ProductName,
                    @event.AvailableQuantity
                });
                await _eventRepository.PersistAsync(@event);

                var newProduct = new ProductRM()
                {
                    Id   = @event.AggregateId,
                    Name = @event.ProductName,
                    AvailableQuantity = @event.AvailableQuantity
                };
                await _repository.InsertAsync(newProduct);

                await _repository.SaveAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #2
0
        public async Task Handle(CartCreated @event, CancellationToken cancellationToken)
        {
            @event.Payload = JsonConvert.SerializeObject(new
            {
                @event.CreatedAt
            });
            await _eventRepository.PersistAsync(@event);

            var cart = new CartRM();

            cart.CreatedAt = @event.CreatedAt;
            cart.Id        = @event.AggregateId;

            await _repository.InsertAsync(cart);

            await _repository.SaveAsync();
        }
 public virtual async Task <bool> InsertAsync(TEntity item, CancellationToken token = default(CancellationToken), Action operationToExecuteBeforeNextOperation = null)
 {
     CheckForObjectAlreadyDisposedOrNot(typeof(CommandDomainServiceAsync <TEntity>).FullName);
     return(await InvokeAfterWrappingWithinExceptionHandling(async() => await _repository.InsertAsync(item, token, operationToExecuteBeforeNextOperation)));
 }
예제 #4
0
 public virtual Task InsertAsync(TEntity entity)
 {
     return(_commandRepository.InsertAsync(entity));
 }
예제 #5
0
 public virtual async Task <bool> InsertAsync(TEntity item, CancellationToken token = default, Action operationToExecuteBeforeNextOperation = null)
 {
     return(await InvokeAfterWrappingWithinExceptionHandling(async() => await _repository.InsertAsync(item, token, operationToExecuteBeforeNextOperation).ConfigureAwait(false)));
 }