GrammarExample.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 GrammarExample
  10. {
  11. public String id { get; set; }
  12. public String name { get; set; }
  13. public String description { get; set; }
  14. public String introduction { get; set; }
  15. public String picture { get; set; }
  16. public String content { get; set; }
  17. public String contentType { get; set; }
  18. public String grammarID { get; set; }
  19. // parse data from JSON data
  20. public GrammarExample() { }
  21. public GrammarExample(string json) : this(JObject.Parse(json))
  22. { }
  23. public GrammarExample(JObject jObject)
  24. {
  25. if (jObject != null)
  26. {
  27. id = (string)jObject["ID"];
  28. name = (string)jObject["NAME"];
  29. description = (string)jObject["DESCRIPTION"];
  30. introduction = (string)jObject["INTRODUCTION"];
  31. picture = UtilsController.GetContentPath.GrammarContentPath + (string)jObject["PICTURE"];
  32. contentType = (string)jObject["CONTENT_TYPE"];
  33. if (contentType == UtilsController.GetContentType.AUDIO_FILE ||
  34. contentType == UtilsController.GetContentType.PICTURE_FILE ||
  35. contentType == UtilsController.GetContentType.VIDEO_FILE)
  36. content = UtilsController.GetContentPath.GrammarContentPath + (string)jObject["CONTENT"];
  37. else
  38. content = (string)jObject["CONTENT"];
  39. grammarID = (string)jObject["GRAMMAR_ID"];
  40. }
  41. }
  42. }
  43. }