예제 #1
0
        public async void insertSampleSelectedGoalsToDbForTesting()
        {
            clearSelectedGoalDb();
            Debug.WriteLine("###############  insert sample diary");

            Goal goal = goalDatabase.GetTheFirstGoal(); //this works

            if (goal == null)
            {
                //in case of empty goalDb
                goal = new Goal(0, "Sample Title", "Desc", "Cat");
            }
            SelectedGoal newSGoal = new SelectedGoal(goal);

            SelectedGoals.Add(newSGoal);

            foreach (var selectedGoal in SelectedGoals)
            {
                await selectedGoalDatabase.InsertSelectedGoal(selectedGoal);
            }
            Close(this);
        }
예제 #2
0
        public async void loadSelectedGoalsFromDb()
        {
            //Debug.WriteLine("###############  load diary from db");
            SelectedGoals.Clear();
            //Debug.WriteLine("###############  get selected goals from db");
            var selectedGoalsInDb = selectedGoalDatabase.GetSelectedGoals();

            foreach (var selectedGoal in selectedGoalsInDb)
            {
                try
                {
                    //Debug.WriteLine("###############  details = " + selectedGoal.toString());

                    Goal thisGoal = goalDatabase.GetGoal(selectedGoal.GoalId).Result;
                    if (thisGoal == null)
                    {
                        thisGoal = new Goal(0, "Goal not found", "", "");
                    }
                    selectedGoal.setGoal(thisGoal);//to update information of Goal object

                    if (selectedGoal.Status.Equals("STARTED") && selectedGoal.DateUpdated.Date < DateTime.Today.ToLocalTime().Date)
                    {
                        selectedGoal.expire();
                        selectedGoalDatabase.UpdateSelectedGoal(selectedGoal);
                    }


                    SelectedGoals.Add(selectedGoal);
                }
                catch (Exception e)
                {
                    //possibly NullReferenceException

                    Debug.WriteLine("###############  exception: " + e.Message);
                    await selectedGoalDatabase.DeleteSelectedGoal(selectedGoal.Id);
                }
            }
        }
예제 #3
0
        public async void loadSelectedGoalsFromDbToday()
        {
            //Debug.WriteLine("###############  load goal today from db");
            SelectedGoals.Clear();
            var selectedGoalsInDb = selectedGoalDatabase.GetSelectedGoalsToday().Result;

            foreach (var selectedGoal in selectedGoalsInDb)
            {
                if (!selectedGoal.Status.Equals("DELETED")) //if goal is deleted, dont display it
                {
                    try
                    {
                        Goal thisGoal = goalDatabase.GetGoal(selectedGoal.GoalId).Result;
                        selectedGoal.setGoal(thisGoal);//to update information of Goal object
                        SelectedGoals.Add(selectedGoal);
                    }
                    catch (Exception e)
                    {
                        //possibly NullReferenceException
                        Debug.WriteLine("###############  exception: " + e.Message);
                    }
                }
            }
        }
예제 #4
0
 public bool IsToBeDeleted(Guid index)
 {
     return(SelectedGoals.Any(selectedGoal => goals.Contains(selectedGoal)));
 }