History.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. namespace NEducation.Code
  7. {
  8. public class History
  9. {
  10. public List<HistoryElement> listCourseHistory { get; set; }
  11. // parse data from JSON data
  12. public History() { }
  13. public History(string json) : this(JObject.Parse(json))
  14. { }
  15. public History(JObject jObject)
  16. {
  17. if (jObject != null)
  18. {
  19. var list = jObject["LIST_COURSE_HIS"];
  20. if (list != null && list.HasValues)
  21. {
  22. listCourseHistory = new List<HistoryElement>();
  23. JArray a = (JArray)list;
  24. foreach (JObject o in a.Children<JObject>())
  25. {
  26. listCourseHistory.Add(new HistoryElement(o));
  27. }
  28. }
  29. }
  30. }
  31. }
  32. public class HistoryElement
  33. {
  34. public string totalLesson { get; set; }
  35. public string totalLessonLearn { get; set; }
  36. public string percent { get; set; }
  37. public string id { get; set; }
  38. public string categoryId { get; set; }
  39. public string code { get; set; }
  40. public string name { get; set; }
  41. public string description { get; set; }
  42. public string introduction { get; set; }
  43. public string isLearn { get; set; }
  44. public string iconPath { get; set; }
  45. public string logoPath { get; set; }
  46. public string expDate { get; set; }
  47. // listLesson always null
  48. public string listLesson { get; set; }
  49. // parse data from JSON data
  50. public HistoryElement() { }
  51. public HistoryElement(string json) : this(JObject.Parse(json))
  52. { }
  53. public HistoryElement(JObject jObject)
  54. {
  55. if (jObject != null)
  56. {
  57. totalLesson = (string)jObject["TOTAL_LESSON"];
  58. totalLessonLearn = (string)jObject["TOTAL_LESSON_LEARN"];
  59. percent = (string)jObject["PERCENT"];
  60. description = (string)jObject["DESCRIPTION"];
  61. iconPath = (string)jObject["ICON_PATH"];
  62. id = (string)jObject["ID"];
  63. categoryId = (string)jObject["CATEGORY_ID"];
  64. code = (string)jObject["CODE"];
  65. name = (string)jObject["NAME"];
  66. introduction = (string)jObject["INTRODUCTION"];
  67. isLearn = (string)jObject["IS_LEARN"];
  68. logoPath = (string)jObject["LOGO_PAHT"];
  69. expDate = (string)jObject["EXP_DATE"];
  70. listLesson = (string)jObject["LIST_LESSON"];
  71. }
  72. }
  73. }
  74. }