Course.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using NEducation.Controllers;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. namespace NEducation.Code
  8. {
  9. public class Course
  10. {
  11. public String id { get; set; }
  12. public String categoryId { get; set; }
  13. public String code { get; set; }
  14. public String name { get; set; }
  15. public String isLearn { get; set; }
  16. public String description { get; set; }
  17. public String introduction { get; set; }
  18. public String iconPath { get; set; }
  19. public String logoPath { get; set; }
  20. public List<Lesson> listLesson { get; set; }
  21. public Course() { }
  22. public Course(string json) : this(JObject.Parse(json))
  23. { }
  24. public Course(JObject jObject)
  25. {
  26. if (jObject != null)
  27. {
  28. id = (string)jObject["ID"];
  29. code = (string)jObject["CODE"];
  30. name = (string)jObject["NAME"];
  31. isLearn = (string)jObject["IS_LEARN"];
  32. categoryId = (string)jObject["CATEGORY_ID"];
  33. description = (string)jObject["DESCRIPTION"];
  34. introduction = (string)jObject["INTRODUCTION"];
  35. iconPath = UtilsController.GetContentPath.CourseContentPath + (string)jObject["ICON_PATH"];
  36. logoPath = UtilsController.GetContentPath.CourseContentPath + (string)jObject["LOGO_PAHT"];
  37. var list = jObject["LIST_LESSON"];
  38. if (list != null && list.HasValues)
  39. {
  40. listLesson = new List<Lesson>();
  41. JArray a = (JArray)list;
  42. foreach (JObject o in a.Children<JObject>())
  43. {
  44. listLesson.Add(new Lesson(o));
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }