Category.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 Category
  10. {
  11. public String id { get; set; }
  12. public String code { get; set; }
  13. public String name { get; set; }
  14. public String description { get; set; }
  15. public String introduction { get; set; }
  16. public String iconPath { get; set; }
  17. public String logoPath { get; set; }
  18. public String serviceId { get; set; }
  19. public List<Course> listCourse { get; set; }
  20. // parse data from JSON data
  21. public Category() { }
  22. public Category(string json) : this(JObject.Parse(json))
  23. { }
  24. public Category(JObject jObject)
  25. {
  26. if (jObject != null)
  27. {
  28. id = (string)jObject["ID"];
  29. code = (string)jObject["CODE"];
  30. name = (string)jObject["NAME"];
  31. description = (string)jObject["DESCRIPTION"];
  32. introduction = (string)jObject["INTRODUCTION"];
  33. iconPath = UtilsController.GetContentPath.CategoryContentPath + (string)jObject["ICON_PATH"];
  34. logoPath = UtilsController.GetContentPath.CategoryContentPath + (string)jObject["LOGO_PAHT"];
  35. serviceId = (string)jObject["SERVICE_ID"];
  36. var list = jObject["LIST_COURSE"];
  37. if (list != null && list.HasValues)
  38. {
  39. listCourse = new List<Course>();
  40. JArray a = (JArray)list;
  41. foreach (JObject o in a.Children<JObject>())
  42. {
  43. listCourse.Add(new Course(o));
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }