void priorityDownButten_Click(object sender, EventArgs e) { TodoItemPriorityDecreased @event = new TodoItemPriorityDecreased(todoItem.id); state.LoadAndPersist(@event); }
public IEvent transformEvent(TodoItemPriorityDecreased toTransform, IEvent transformAgainst) { if (transformAgainst.GetType().Equals(typeof(TodoItemDeleted))) { if (toTransform.aggregateId == ((TodoItemDeleted)transformAgainst).aggregateId) //Delete todo item when other side has also deleted it. No problem, remove this event. return new Unused(); } else if (transformAgainst.GetType().Equals(typeof(TodoItemPriorityChanged))) { //Can just append. } else if (transformAgainst.GetType().Equals(typeof(TodoItemPriorityDecreased))) { //Can just append } else if (transformAgainst.GetType().Equals(typeof(TodoItemPriorityIncreased))) { //Can also just append. } else if (transformAgainst.GetType().Equals(typeof(TodoItemsDeleted))) { //If the item deleted is deleted by multiple on the server, remove this event if (((TodoItemsDeleted)transformAgainst).aggregateIds.Contains(toTransform.aggregateId)) return new Unused(); } return toTransform; }