using NEducation.Controllers; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace NEducation.Code { public class Grammar { public String id { get; set; } public String name { get; set; } public String description { get; set; } public String introduction { get; set; } //public String example { get; set; } //public String content { get; set; } //public String contentType { get; set; } public String picture { get; set; } public String lessonID { get; set; } public List listGrammarExample { get; set; } // parse data from JSON data public Grammar() { } public Grammar(string json) : this(JObject.Parse(json)) { } public Grammar(JObject jObject) { if (jObject != null) { id = (string)jObject["ID"]; name = (string)jObject["NAME"]; description = (string)jObject["DESCRIPTION"]; introduction = (string)jObject["INTRODUCTION"]; picture = UtilsController.GetContentPath.GrammarContentPath + (string)jObject["PICTURE"]; lessonID = (string)jObject["LESSON_ID"]; //contentType = (string)jObject["CONTENT_TYPE"]; //if (contentType == UtilsController.GetContentType.AUDIO_FILE || // contentType == UtilsController.GetContentType.PICTURE_FILE || // contentType == UtilsController.GetContentType.VIDEO_FILE) // content = UtilsController.GetContentPath.GrammarContentPath + (string)jObject["CONTENT"]; //else // content = (string)jObject["CONTENT"]; var list = jObject["LIST_GRAMMAR_EX"]; if (list != null && list.HasValues) { listGrammarExample = new List(); JArray a = (JArray)list; foreach (JObject o in a.Children()) { listGrammarExample.Add(new GrammarExample(o)); } } } } } }