/// <summary> /// Handle ProductActivatedEvent. /// </summary> /// <param name="productActivatedEvent">ProductActivatedEvent instance.</param> /// <param name="cancellationToken">Cancellation token.</param> /// <returns>Asynchronous task which can be awaited for completion.</returns> public async Task HandleAsync(ProductActivatedEvent productActivatedEvent, CancellationToken cancellationToken = default(CancellationToken)) { var product = await _productReadSideRepository.GetProductByIdAsync(productActivatedEvent.ProductId, cancellationToken); // Set read-side product to active. product.IsActive = true; await _productReadSideRepository.UpdateProductAsync(product, cancellationToken); }
private async Task ActivateProduct(ProductActivatedEvent @event) { var entity = new ProductEntity { Id = @event.Id, PartitionKey = @event.Type.ToString(), RowKey = @event.Id.ToString(), Timestamp = DateTime.UtcNow, IsActive = true, ETag = "*" }; await _tableStorageRepository.UpdateAsync(TableReference, entity).ConfigureAwait(false); }
private void OnProductActivatedEvent(ProductActivatedEvent domainEvent) { IsActive = true; }