| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace NEducation.Code
- {
- public class ListLessonData
- {
- public string status { get; set; }
- public string message { get; set; }
- public List<Vocabulary> vocabularies { get; set; }
- public List<Grammar> grammars { get; set; }
- public List<Listening> listenings { get; set; }
- public List<Question> questions { get; set; }
- // parse data from JSON data
- public ListLessonData() { }
- public ListLessonData(string json) : this(JObject.Parse(json))
- { }
- public ListLessonData(JObject jObject)
- {
- if (jObject != null)
- {
- status = (string)jObject["status"];
- message = (string)jObject["message"];
- var listVocab = jObject["LIST_VOCABULARY"];
- if (listVocab != null && listVocab.HasValues)
- {
- vocabularies = new List<Vocabulary>();
- JArray a = (JArray)listVocab;
- foreach (JObject o in a.Children<JObject>())
- {
- vocabularies.Add(new Vocabulary(o));
- }
- }
- var listListen = jObject["LIST_LISTEN"];
- if (listListen != null && listListen.HasValues)
- {
- listenings = new List<Listening>();
- JArray a = (JArray)listListen;
- foreach (JObject o in a.Children<JObject>())
- {
- listenings.Add(new Listening(o));
- }
- }
- var listGrammar = jObject["LIST_GRAMMAR"];
- if (listGrammar != null && listGrammar.HasValues)
- {
- grammars = new List<Grammar>();
- JArray a = (JArray)listGrammar;
- foreach (JObject o in a.Children<JObject>())
- {
- grammars.Add(new Grammar(o));
- }
- }
- var listQuestion = jObject["LIST_QUESTION"];
- if (listQuestion != null && listQuestion.HasValues)
- {
- questions = new List<Question>();
- JArray a = (JArray)listQuestion;
- foreach (JObject o in a.Children<JObject>())
- {
- questions.Add(new Question(o));
- }
- }
- }
- }
- }
- }
|