using NEducation.Controllers; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace NEducation.Code { public class Category { public String id { get; set; } public String code { get; set; } public String name { get; set; } public String description { get; set; } public String introduction { get; set; } public String iconPath { get; set; } public String logoPath { get; set; } public String serviceId { get; set; } public List listCourse { get; set; } // parse data from JSON data public Category() { } public Category(string json) : this(JObject.Parse(json)) { } public Category(JObject jObject) { if (jObject != null) { id = (string)jObject["ID"]; code = (string)jObject["CODE"]; name = (string)jObject["NAME"]; description = (string)jObject["DESCRIPTION"]; introduction = (string)jObject["INTRODUCTION"]; iconPath = UtilsController.GetContentPath.CategoryContentPath + (string)jObject["ICON_PATH"]; logoPath = UtilsController.GetContentPath.CategoryContentPath + (string)jObject["LOGO_PAHT"]; serviceId = (string)jObject["SERVICE_ID"]; var list = jObject["LIST_COURSE"]; if (list != null && list.HasValues) { listCourse = new List(); JArray a = (JArray)list; foreach (JObject o in a.Children()) { listCourse.Add(new Course(o)); } } } } } }