public async Task AddItem(NormalizedString itemText, NormalizedString categoryText = null) { TodoCategory d = null; if (categoryText != null) { d = await GetCategory(categoryText); } if (d == null) { d = Categories.Single(x => x.IsDefaultCategory); } var i = d.Items.FirstOrDefault(x => x.Text == itemText); if (i == null) { i = new TodoItem { Text = itemText }; d.Items.Add(i); } TriggerOnChange(); }
public async Task ConvertItemToCategory(NormalizedString categoryText, NormalizedString itemText) { var d = await GetCategory(itemText); if (d != null) { return; } var category = await GetCategory(categoryText); var item = await GetItem(categoryText, itemText); category.Items.Remove(item); var newCategory = new TodoCategory { Text = item.Text, Items = new List <TodoItem>() }; Categories.Add(newCategory); await SetIsCategoryFocused(newCategory.Text, true); TriggerOnChange(); }