Vocabulary.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using NEducation.Controllers;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Web;
  5. namespace NEducation.Code
  6. {
  7. public class Vocabulary : PostObj
  8. {
  9. public String id { get; set; }
  10. public String nameGlobal { get; set; }
  11. public String nameLocal { get; set; }
  12. public String descriptionGlobal { get; set; }
  13. public String descriptionLocal { get; set; }
  14. public String introductionGlobal { get; set; }
  15. public String introductionLocal { get; set; }
  16. public String example { get; set; }
  17. public String spell { get; set; }
  18. public String content { get; set; }
  19. public String contentType { get; set; }
  20. public String picture { get; set; }
  21. public String lessonID { get; set; }
  22. // parse data from JSON data
  23. public Vocabulary() { }
  24. public Vocabulary(string json) : this(JObject.Parse(json))
  25. { }
  26. public Vocabulary(JObject jObject)
  27. {
  28. if (jObject != null)
  29. {
  30. id = (string)jObject["ID"];
  31. nameGlobal = (string)jObject["NAME_GLOBAL"];
  32. nameLocal = (string)jObject["NAME_LOCAL"];
  33. descriptionGlobal = (string)jObject["DESCRIPTION_GLOBAL"];
  34. descriptionLocal = (string)jObject["DESCRIPTION_LOCAL"];
  35. introductionGlobal = (string)jObject["INTRODUCTION_GLOBAL"];
  36. introductionLocal = (string)jObject["INTRODUCTION_LOCAL"];
  37. example = (string)jObject["EXAMPLE"];
  38. spell = (string)jObject["SPELL"];
  39. contentType = (string)jObject["CONTENT_TYPE"];
  40. if (contentType == UtilsController.GetContentType.AUDIO_FILE ||
  41. contentType == UtilsController.GetContentType.PICTURE_FILE ||
  42. contentType == UtilsController.GetContentType.VIDEO_FILE)
  43. content = UtilsController.GetContentPath.VocabularyContentPath + (string)jObject["CONTENT"];
  44. else
  45. content = (string)jObject["CONTENT"];
  46. picture = UtilsController.GetContentPath.VocabularyContentPath + (string)jObject["PICTURE"];
  47. lessonID = (string)jObject["LESSON_ID"];
  48. System.Diagnostics.Debug.WriteLine("picture " + picture);
  49. }
  50. }
  51. }
  52. }