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