예제 #1
0
 public void Init(int selectedGoalId)
 {
     try
     {
         selectedGoal = selectedGoalDatabase.GetSelectedGoal(selectedGoalId).Result;
         Goal thisGoal = goalDatabase.GetGoal(selectedGoal.GoalId).Result;
         selectedGoal.setGoal(thisGoal);//to update information of Goal object
     }
     catch (Exception e)
     {
         //possibly NullReferenceException
         Debug.WriteLine("exception: " + e.Message);
     }
 }
예제 #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);
                    }
                }
            }
        }