public void CategoryRestoredEvent_Ctor_Should_Set_Arguments_Correctly() { Guid categoryId = Guid.NewGuid(); var @event = new CategoryRestoredEvent(categoryId); Assert.Equal(categoryId, @event.CategoryId); Assert.Equal(categoryId, @event.AggregateId); Assert.Equal(typeof(Catalog.Models.Category), @event.AggregateType); }
/// <summary> /// <see cref="IHandleEvent{TEvent}.Handle(TEvent)"/> /// </summary> /// <param name="event"></param> public void Handle(CategoryRestoredEvent @event) { try { EventStore.Save(@event); } catch { throw; } }
public async Task RestoreCategory(Guid categoryId) { try { var category = await Repository.GetByKeyAsync <Category>(categoryId); category.Restore(); await Repository.SaveChangesAsync(); var @event = new CategoryRestoredEvent(categoryId); EventBus.RaiseEvent(@event); } catch { throw; } }
/// <summary> /// Implementation of <see cref="ICategoryCommands.RestoreCategory(Guid)"/> /// </summary> /// <param name="categoryId">The category id</param> /// <returns></returns> public virtual async Task RestoreCategory(Guid categoryId) { try { if (categoryId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(categoryId)); } var category = await Repository.GetByKeyAsync <Category>(categoryId); category.Restore(); await Repository.SaveChangesAsync(); var @event = new CategoryRestoredEvent(categoryId); EventBus.RaiseEvent(@event); } catch { throw; } }