public void ProductRestoredEvent_Ctor_Should_Set_Arguments_Correctly() { Guid productId = Guid.NewGuid(); var @event = new ProductRestoredEvent(productId); Assert.Equal(productId, @event.ProductId); Assert.Equal(productId, @event.AggregateId); Assert.Equal(typeof(Catalog.Models.Product), @event.AggregateType); }
public void Handle(ProductRestoredEvent @event) { try { EventStore.Save(@event); } catch { throw; } }
public async Task RestoreProduct(Guid productId) { try { var product = await Repository.GetByKeyAsync <Product>(productId); product.Restore(); await Repository.SaveChangesAsync(); var @event = new ProductRestoredEvent(productId); EventBus.RaiseEvent(@event); } catch { throw; } }
/// <summary> /// Implementation of <see cref="IProductCommands.RestoreProduct(Guid)"/> /// </summary> /// <param name="productId">The product id</param> /// <returns></returns> public virtual async Task RestoreProduct(Guid productId) { try { if (productId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(productId)); } var product = await Repository.GetByKeyAsync <Product>(productId); product.Restore(); await Repository.SaveChangesAsync(); var @event = new ProductRestoredEvent(productId); EventBus.RaiseEvent(@event); } catch { throw; } }