private async Task ExecuteItem(ProgressItem item) { await item.Execute(); Completed.Add(item); if (!string.IsNullOrEmpty(item.Message)) { InError.Add(item); } }
public void CheckNiegbourhood() { if (LastSelected != null) { LastSelected.ChangeTexture(2); if (LastSelected.TmpNeighbours.Count <= 0) { Completed.Add(LastSelected); LastSelected.ChangeTexture(3); } } Selected.ChangeTexture(2); if (Selected.TmpNeighbours.Count <= 0) { Completed.Add(Selected); Selected.ChangeTexture(3); } }
public async Task OnAppearing() { var goalsFromDb = await _goalDatabase.GetGoalsAsync(); _morningGoals.Clear(); _afternoonGoals.Clear(); _eveningGoals.Clear(); Completed.Clear(); foreach (var goal in goalsFromDb) { if ((DateTime.Now.Date - goal.LastCompletion.Date).TotalDays == 0) { Completed.Add(goal); } else { AddGoalToToDoList(new GoalViewModel(goal)); } } }
public MainPageViewModel(GoalDatabase goalDatabase, INavigationService navigationService) { _goalDatabase = goalDatabase; _navigationService = navigationService; this.Todo = new ObservableCollection <GroupedGoals>(); this.Completed = new ObservableCollection <Goal>(); this.NoCompleted = true; this.HasCompleted = false; _morningGoals = new GroupedGoals("Morning", "AM"); _afternoonGoals = new GroupedGoals("Afternoon", "PM"); _eveningGoals = new GroupedGoals("Evening", "PM"); this.Todo.Add(_morningGoals); this.Todo.Add(_afternoonGoals); this.Todo.Add(_eveningGoals); this.Completed.CollectionChanged += Completed_CollectionChanged; this.AddCommand = new Command(async() => { await _navigationService.NavigateToEditAsync(); }); this.EditCommand = new Command(async(obj) => { await _navigationService.NavigateToEditAsync((int)obj); }); this.DeleteCommand = new Command(async(obj) => { int goalId = (int)obj; await _goalDatabase.DeactivateGoal(goalId); Completed.Remove(Completed.FirstOrDefault(g => g.Id == goalId)); RemoveGoalFromToDoList(goalId); DependencyService.Get <INotificationManager>().Cancel(goalId); }); this.CompleteCommand = new Command(async(obj) => { int goalId = (int)obj; var goal = await _goalDatabase.GetGoalAsync(goalId); var updatedGoal = await _goalDatabase.AddGoalCompletion(goal, DateTime.Now); RemoveGoalFromToDoList(goalId); Completed.Add(updatedGoal); }); this.UndoCompleteCommand = new Command(async(obj) => { int goalId = (int)obj; var goal = await _goalDatabase.GetGoalAsync(goalId); var updatedGoal = await _goalDatabase.UndoGoalCompletion(goalId); Completed.Remove(Completed.FirstOrDefault(g => g.Id == goalId)); AddGoalToToDoList(new GoalViewModel(updatedGoal)); }); }