public void CustomAttributeDeletedEvent_Ctor_Should_Set_Arguments_Correctly() { Guid attributeId = Guid.NewGuid(); var @event = new CustomAttributeDeletedEvent(attributeId); Assert.Equal(attributeId, @event.AttributeId); Assert.Equal(attributeId, @event.AggregateId); Assert.Equal(typeof(Catalog.Models.CustomAttribute), @event.AggregateType); }
/// <summary> /// <see cref="IHandleEvent{TEvent}.Handle(TEvent)"/> /// </summary> /// <param name="event"></param> public void Handle(CustomAttributeDeletedEvent @event) { try { EventStore.Save(@event); } catch { throw; } }
public async Task DeleteCustomAttribute(Guid attributeId) { try { var attribute = await Repository.GetByKeyAsync <CustomAttribute>(attributeId); attribute.Delete(); await Repository.SaveChangesAsync(); var @event = new CustomAttributeDeletedEvent(attributeId); EventBus.RaiseEvent(@event); } catch { throw; } }
/// <summary> /// Implementation of <see cref="ICustomAttributesCommands.DeleteCustomAttribute(Guid)"/> /// </summary> /// <param name="attributeId">The custom attribute id</param> /// <returns></returns> public async Task DeleteCustomAttribute(Guid attributeId) { try { if (attributeId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(attributeId)); } var attribute = await Repository.GetByKeyAsync <CustomAttribute>(attributeId); attribute.Delete(); await Repository.SaveChangesAsync(); var @event = new CustomAttributeDeletedEvent(attributeId); EventBus.RaiseEvent(@event); } catch { throw; } }