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); } }
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); } } }
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); } } } }