public void BrandRestoredEvent_Ctor_Should_Set_Arguments_Correctly() { Guid brandId = Guid.NewGuid(); var @event = new BrandRestoredEvent(brandId); Assert.Equal(brandId, @event.BrandId); Assert.Equal(brandId, @event.AggregateId); Assert.Equal(typeof(Catalog.Models.Brand), @event.AggregateType); }
public void Handle(BrandRestoredEvent @event) { try { EventStore.Save(@event); } catch { throw; } }
public async Task RestoreBrand(Guid brandId) { try { var brand = await Repository.GetByKeyAsync <Brand>(brandId); brand.Restore(); await Repository.SaveChangesAsync(); var @event = new BrandRestoredEvent(brandId); EventBus.RaiseEvent(@event); } catch { throw; } }
/// <summary> /// Implementation of <see cref="IBrandCommands.RestoreBrand(Guid)"/> /// </summary> /// <param name="brandId">The brand's id</param> /// <returns></returns> public virtual async Task RestoreBrand(Guid brandId) { try { if (brandId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(brandId)); } var brand = await Repository.GetByKeyAsync <Brand>(brandId); brand.Restore(); await Repository.SaveChangesAsync(); var @event = new BrandRestoredEvent(brandId); EventBus.RaiseEvent(@event); } catch { throw; } }