private static TicketQuestion AddQuestion(int screenId, string title, int?parentscreenId) { var newQuestion = new TicketQuestion { ScreenId = screenId, ScreenTitle = title, ParentScreenId = parentscreenId }; return(newQuestion); }
private void InitializeTicketQuestion() { FragmentTicketQuestion = GetArgument <TicketQuestion>(RaiseTicketActivity.TicketFragment); Logger.Verbose(FragmentTicketQuestion.ScreenTitle); }
public override void UpdateScreen() { try { if (TicketQuestionListDefintion == null) { using (var sr = new StreamReader(Assets.Open("ticketscreens.json"))) { //load the screen definitions from the json file located in the Assets folder TicketQuestionListDefintion = sr.ReadToEnd(); } } if (TicketQuestionListDefintion != null) { //deserialize the json structure TicketQuestionList = JsonConvert.DeserializeObject <List <TicketQuestion> >(TicketQuestionListDefintion); Logger.Verbose("Deserialized Screen List Count : " + TicketQuestionList.Count()); //if we have list of questions if (TicketQuestionList.Any()) { TicketQuestion startTicketQuestion = null; if (StepAnswersListDefintion != null) { StepAnswersList = JsonConvert.DeserializeObject <List <StepAnswer> >(StepAnswersListDefintion); } //determine the starting screen based on whether we have an existing list of step answers if (StepAnswersList == null) { //startTicketQuestion = TicketQuestionList.ElementAt(0); startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == _startScreenId); } else { //if there is persisted list, get the last one and use that as the starting point if (StepAnswersList.Any()) { var lastStepAnswer = StepAnswersList.ElementAt(StepAnswersList.Count() - 1); Logger.Verbose("Last Step to be reloaded : " + lastStepAnswer.StepId); startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == lastStepAnswer.StepId); } else { //startTicketQuestion = TicketQuestionList.ElementAt(0); startTicketQuestion = TicketQuestionList.Find(q => q.ScreenId == _startScreenId); } } if (startTicketQuestion != null) { if (StepAnswersList == null) { StepAnswersList = new List <StepAnswer>(); } _ticketFragment = new FragmentTicket(); _ticketFragment.SetArgument(TicketFragment, startTicketQuestion); ShowFragment(_ticketFragment); } } } } catch (Exception ex) { Logger.Verbose(ex.Message); return; } }