Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. IEnumerable<StartParticularSurvey> _questionList;
  2. IEnumerable<StartParticularSurvey> _answerList;
  3.  
  4. var response = e.Result.ToString();
  5. var result = StartParticularSurvey.FromJson(response);
  6. if (result[0][0].bit_HasError == true)
  7. {
  8. Device.BeginInvokeOnMainThread(() =>
  9. {
  10. Navigation.PushAsync(new UserSurveyList());
  11. DisplayAlert("Alert!", result[0][0].vchar_ErrorMsg, "Ok");
  12. });
  13. }
  14. else
  15. {
  16. Device.BeginInvokeOnMainThread(() =>
  17. {
  18. var questionDataset = result[1][0];
  19. var answerDataset = result[2][0];
  20. _questionList = questionDataset as IEnumerable<StartParticularSurvey>;
  21. _answerList = answerDataset as IEnumerable<StartParticularSurvey>;
  22. lvSurveyQuestion.ItemsSource = _questionList;
  23. lvSurveyAnswer.itemSource = _answerList; //Here is where the .cs is not picking up and i know why.
  24. });
  25. }
  26.  
  27. <ListView x:Name="lvSurveyQuestion">
  28. <ListView.ItemTemplate>
  29. <DataTemplate>
  30. <ViewCell>
  31. <StackLayout>
  32. <Label Text="{binding data here}"/>
  33. <ListView x:Name="lvSurveyAnswer">
  34. <ListView.ItemTemplate>
  35. <DataTemplate>
  36. <ViewCell>
  37. <StackLayout>
  38. <Label Text="{binding data here}"/>
  39. <Label Text="{binding data here}"/>
  40. </StackLayout>
  41. </ViewCell>
  42. </DataTemplate>
  43. </ListView.ItemTemplate>
  44. </ListView>
  45. </StackLayout>
  46. </ViewCell>
  47. </DataTemplate>
  48. </ListView.ItemTemplate>
  49. </ListView>
  50.  
  51. namespace IVSConnectMobile.Model
  52. {
  53. public partial class StartParticularSurvey
  54. {
  55. [JsonProperty("bit_HasError", NullValueHandling = NullValueHandling.Ignore)]
  56. public bool? bit_HasError { get; set; }
  57.  
  58. [JsonProperty("vchar_ErrorMsg", NullValueHandling = NullValueHandling.Ignore)]
  59. public string vchar_ErrorMsg { get; set; }
  60.  
  61. [JsonProperty("int_SurveyQuestionID", NullValueHandling = NullValueHandling.Ignore)]
  62. public long? int_SurveyQuestionID { get; set; }
  63.  
  64. [JsonProperty("vchar_Description", NullValueHandling = NullValueHandling.Ignore)]
  65. public string vchar_Description { get; set; }
  66.  
  67. [JsonProperty("vchar_Instruction")]
  68. public string vchar_Instruction { get; set; }
  69.  
  70. [JsonProperty("int_AnswerType", NullValueHandling = NullValueHandling.Ignore)]
  71. public long? int_AnswerType { get; set; }
  72.  
  73. [JsonProperty("vchar_Option", NullValueHandling = NullValueHandling.Ignore)]
  74. public string vchar_Option { get; set; }
  75. }
  76.  
  77. public partial class StartParticularSurvey
  78. {
  79. public static List<List<StartParticularSurvey>> FromJson(string json) => JsonConvert.DeserializeObject<List<List<StartParticularSurvey>>>(json, IVSConnectMobile.Model.Converter.Settings);
  80. }
  81.  
  82. public static class Serialize
  83. {
  84. public static string ToJson(this List<List<StartParticularSurvey>> self) => JsonConvert.SerializeObject(self, IVSConnectMobile.Model.Converter.Settings);
  85. }
  86.  
  87. internal static class Converter
  88. {
  89. public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
  90. {
  91. MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
  92. DateParseHandling = DateParseHandling.None,
  93. Converters = {
  94. new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
  95. },
  96. };
  97. }
  98. }
Add Comment
Please, Sign In to add comment