public void AddWithMerge(ToDoItem item) { bool found = false; //check any existing and just transfer status foreach (ToDoItem tdi in _items) { if (tdi.Description.Equals(item.Description)) { //archived and completed status should be //merged if true for either if (item.Archived || item.IsArchived) { tdi.Archived = true; } if (item.Completed || item.IsCompleted) { tdi.Completed = true; } tdi.Statuses.AddWithMerge(item.Statuses); //Stopwatch sw = new Stopwatch(); //sw.Start(); //tdi.Add(item.Fragment); //sw.Stop(); found = true; } } if (!found) { _items.Add(item); } }
public void UpdateStatus(string item, bool completed, bool archived) { Parser.Parser p = new Parser.Parser(); string itemValue = p.Extract("item", item); if (string.IsNullOrWhiteSpace(itemValue)) { itemValue = item; } ToDoItem tdi = new ToDoItem() { Description = itemValue, Completed = completed, Archived = archived }; //tdi.Add(new Fragment(item)); AddWithMerge(tdi); }