private async Task LoadTodoItemsAsync() { try { IsRefreshing = true; var itemsResult = await _repo.FetchItemsAsync <TodoItem>(); if (itemsResult.IsValid()) { TodoItems = itemsResult.ModelCollection.AsObservableCollection(); if (!TodoItems.Any()) { TodoItems.Add(new TodoItem { Text = "Ghost Item" }); } } } finally { IsRefreshing = false; } }
public TodoContext(DbContextOptions <TodoContext> options) : base(options) { if (TodoItems.Any()) { return; } SeedDummyData(); }
public TodoContext(DbContextOptions <TodoContext> options) : base(options) { if (!TodoItems.Any()) { Add(new TodoItem("Buy a new guitar", false)); Add(new TodoItem("Buy a present for Mike's birthday", false)); Add(new TodoItem("Ring Grandma", true)); } SaveChanges(); }
public ToDoItemStorage() { var todoItem1 = new TodoItem(); todoItem1.Id = TodoItems.Any() ? TodoItems.Keys.Max() + 1 : 1; todoItem1.Name = "Training Session"; todoItem1.IsComplete = false; TodoItems.Add(todoItem1.Id, todoItem1); var todoItem2 = new TodoItem(); todoItem2.Id = TodoItems.Keys.Max() + 1; todoItem2.Name = "Ali and Shahid will Practice"; todoItem2.IsComplete = false; TodoItems.Add(todoItem2.Id, todoItem2); }
/// <summary> /// [Dev] Seed the Todo table with an item. /// </summary> public void DevSeedTodoItem() { while (TodoItems.Any()) { TodoItems.Remove(TodoItems.First()); } TodoItem newItem = new TodoItem(); newItem.Name = "Do The Thing"; Project proj = Projects.First(); newItem.Project = proj; StatusSet statusSet = proj.ValidStatuses; newItem.Status = statusSet.Statuses[0]; ChangeTracker.TrackGraph(newItem, node => node.Entry.State = node.Entry.IsKeySet ? EntityState.Unchanged : EntityState.Added); SaveChanges(); /* * var newFile = new FileRef("test/file.jpg"); * * var user = Users.FirstOrDefault(); * var statusSet = StatusSets.FirstOrDefault(); * * var project = Projects.FirstOrDefault(); * if (project == null) { * System.Console.WriteLine(" !!! Tried to create Todo without project"); * return; * } * EnsureDeepLoaded(Entry(project)); * EnsureDeepLoaded(Entry(project.ValidStatuses)); * var initItem = new TodoItem(project, project.ValidStatuses.Statuses[0]); * initItem.Name = "Init Item"; * initItem.Project = Projects.FirstOrDefault(); * initItem.Files.Add(newFile); * initItem.Tags = "mojo;josie;kibby"; * if (user != null) initItem.Assignee = user; * else System.Console.WriteLine("NULL USER"); * TodoItems.Add(initItem); * SaveChanges();*/ }
public async void SaveTodoItemButton_Click() { if (TodoItems.Any(t => t.Id == TodoItem.Id)) { await ManageAppointment(); await TodoItemRepository.Update(TodoItem); } else { await ManageAppointment(); await TodoItemRepository.Create(TodoItem); } if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }
private void UpdateAllTodoItemsCompletionEnabled() { CanCompleteAllTodoItems.Value = TodoItems.Any(); }