/// <summary> /// When Navigating to the page, sets up the page. The args paramater can contain either a study id or a team id to set up the page from. /// </summary> /// <param name="args"></param> protected override async void OnNavigatedTo(NavigationEventArgs args) { _logic = new Logic.Logic(); _logic._Origin = Frame.BackStack.FirstOrDefault(); if (_logic._Origin == null) { throw new InvalidOperationException("The ManageStudyPage should be navigated to from another page."); } if (args.Parameter.GetType() == typeof (Logic.Logic)) { _logic = args.Parameter as Logic.Logic; SetUpFromLogic(_logic); return; } // Make sure either a team, or study ID is passed, so that a suitable UI to manage the study can be created. var studyArgs = args.Parameter as ManageStudyPageArgs; if (studyArgs == null) { throw new ArgumentException("This page needs to receive either a team or study ID as parameter.", nameof(args)); } // Based on the parameter passed to this page, either load an existing study, or create a new one. try { if (studyArgs.StudyId != null) { await _logic.SetUpFromStudy((int) studyArgs.StudyId); _logic._IsNewStudy = false; SetUpFromLogic(_logic); } else if (studyArgs.TeamId != null) { await _logic.SetUpFromTeam((int) studyArgs.TeamId); _logic._IsNewStudy = true; SetUpFromLogic(_logic); } } catch (Exception) { var dialog = new MessageDialog("Error retrieving from Database") {Title = "Error"}; await dialog.ShowAsync(); Frame.Navigate(_logic._Origin.SourcePageType); } }
/// <summary> /// Navigating to this page with a logic object. /// </summary> /// <param name="args"></param> protected override void OnNavigatedTo(NavigationEventArgs args) { _logic = new Logic.Logic(); var studyArgs = args.Parameter as Logic.Logic; if (studyArgs == null) { throw new ArgumentException("this page needs to recieve a logic as parameter", nameof(args)); } _logic = studyArgs; SetUpFromStudy(_logic._StudyToWorkOn); SetUpCriteria(); }