void priorityTextBox_LostFocus(object sender, EventArgs e)
        {
            if (priorityChanged)
            {
                int parseResult = 0;

                if (Int32.TryParse(priorityTextBox.Text, out parseResult))
                {
                    TodoItemPriorityChanged @event = new TodoItemPriorityChanged(todoItem.id, parseResult);
                    state.LoadAndPersist(@event);
                }
                else
                {
                    priorityTextBox.Text = wrongInput;
                }
                priorityChanged = false;
            }
        }
        /// <summary>
        /// Creates a list of events that changes the priority. 
        /// There are two becuase the priority is changed against another event. 
        /// </summary>
        /// <param name="createdList">The list of current created items. </param>
        /// <returns>A List of two events that change each others priority. </returns>
        private List<IEvent> getRandomTodoItemPriorityChanged()
        {
            List<IEvent> returnList = new List<IEvent>();

            List<TodoItemAggregate> usedPrioritys = getAvailableTodoItems();

            // Get the two items that need to be changed with each other.
            int leftChangee = differentSeedRandom.Next(usedPrioritys.Count);
            TodoItemAggregate leftSide = usedPrioritys.ElementAt(leftChangee);
            // Remove this from list so it does not change with itself.
            usedPrioritys.RemoveAt(leftChangee);

            int rightChangee = differentSeedRandom.Next(usedPrioritys.Count);
            TodoItemAggregate rightSide = usedPrioritys.ElementAt(rightChangee);

            // Added the priority change for the one that recieves the change.
            TodoItemPriorityChanged todoItemPriorityChanged = new TodoItemPriorityChanged(leftSide.id, rightSide.priority);
            returnList.Add(todoItemPriorityChanged);

            // Need to add the change for its counterpart.
            TodoItemPriorityChanged counterTodoItemPriorityChanged = new TodoItemPriorityChanged(rightSide.id, leftSide.priority);
            returnList.Add(counterTodoItemPriorityChanged);

            return returnList;
        }
 public IEvent transformEvent(TodoItemPriorityChanged 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)))
     {
         if (((TodoItemPriorityChanged)transformAgainst).aggregateId == toTransform.aggregateId)
         {
             //Same change? Do nothing.
             if (((TodoItemPriorityChanged)transformAgainst).Equals(toTransform))
                 return new Unused();
             //Else conflict
             return null;
         }
     }
     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;
 }