| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using Microsoft.Extensions.Configuration;
- using Newtonsoft.Json.Linq;
- using SuperAdmin.Controllers;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace SuperAdmin.Models.Object
- {
- public class RowStructure
- {
- public String id { get; set; }
- public String parent_id { get; set; }
- public String sv_id { get; set; }
- public String code { get; set; }
- public String name { get; set; }
- public String[] names { get; set; }
- public String name_global { get; set; }
- public String name_global1 { get; set; }
- public String name_global2 { get; set; }
- public String name_local { get; set; }
- public String description { get; set; }
- public String[] descriptions { get; set; }
- public String description_global { get; set; }
- public String description_global1 { get; set; }
- public String description_global2 { get; set; }
- public String description_local { get; set; }
- public String introduction { get; set; }
- public String[] introductions { get; set; }
- public String introduction_global { get; set; }
- public String introduction_global1 { get; set; }
- public String introduction_global2 { get; set; }
- public String introduction_local { get; set; }
- public String icon { get; set; }
- public String logo { get; set; }
- public String realIcon { get; set; }
- public String realLogo { get; set; }
- public String content { get; set; }
- public String[] contents { get; set; }
- public String content_global { get; set; }
- public String content_global1 { get; set; }
- public String content_global2 { get; set; }
- public String content_type { get; set; }
- public String created_date { get; set; }
- public String update_date { get; set; }
- public String from_date { get; set; }
- public String to_date { get; set; }
- public String province_id { get; set; }
- public String topic_id { get; set; }
- public String level { get; set; }
- public String is_read { get; set; }
- // 1 publish - 0 draft
- public String status { get; set; }
- // to determine showing or not
- public String is_show { get; set; }
- // to distinguish (1) admin and (0) user
- public String permission { get; set; }
- public String note { get; set; }
- // enews
- public String service_id { get; set; }
- public RowStructure() { }
- public RowStructure(IConfiguration configuration, string json) : this(configuration, JObject.Parse(json))
- { }
- public RowStructure(IConfiguration configuration, JObject jObject)
- {
- if (jObject != null)
- {
- id = (string)jObject["ID"];
- parent_id = (string)jObject["PARENT_ID"];
- sv_id = (string)jObject["SV_ID"];
- code = (string)jObject["CODE"];
- name = (string)jObject["NAME"];
- name_global = (string)jObject["NAME_GLOBAL"];
- name_global1 = (string)jObject["NAME_GLOBAL1"];
- name_global2 = (string)jObject["NAME_GLOBAL2"];
- name_local = (string)jObject["NAME_LOCAL"];
- names = new string[] { name_local, name_global, name_global1, name_global2 };
- description = (string)jObject["DESCRIPTION"];
- description_global = (string)jObject["DESCRIPTION_GLOBAL"];
- description_global1 = (string)jObject["DESCRIPTION_GLOBAL1"];
- description_global2 = (string)jObject["DESCRIPTION_GLOBAL2"];
- description_local = (string)jObject["DESCRIPTION_LOCAL"];
- descriptions = new string[] { description_local, description_global, description_global1, description_global2 };
- introduction = (string)jObject["INTRODUCTION"];
- introduction_global = (string)jObject["INTRODUCTION_GLOBAL"];
- introduction_global1 = (string)jObject["INTRODUCTION_GLOBAL1"];
- introduction_global2 = (string)jObject["INTRODUCTION_GLOBAL2"];
- introduction_local = (string)jObject["INTRODUCTION_LOCAL"];
- introductions = new string[] { introduction_local, introduction_global, introduction_global1, introduction_global2 };
- level = (string)jObject["LEVEL"];
- permission = (string)jObject["TYPE"];
- String img = (string)jObject["ICON"];
- icon = img == null || img == "" ? "" : configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + "/" + img;
- realIcon = (string)jObject["ICON"];
- img = (string)jObject["LOGO"];
- logo = img == null || img == "" ? "" : configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + "/" + img;
- realLogo = img;
- content = (string)jObject["CONTENT"];
- content_global = (string)jObject["CONTENT_GLOBAL"];
- content_global1 = (string)jObject["CONTENT_GLOBAL1"];
- content_global2 = (string)jObject["CONTENT_GLOBAL2"];
- content_type = (string)jObject["CONTENT_TYPE"];
- contents = new string[] { content, content_global, content_global1, content_global2 };
- from_date = (string)jObject["FROM_DATE"];
- to_date = (string)jObject["TO_DATE"];
- created_date = (string)jObject["CREATED_DATE"];
- update_date = (string)jObject["UPDATE_DATE"];
- province_id = (string)jObject["PROVINCE_ID"];
- topic_id = (string)jObject["TOPIC_ID"];
- is_read = (string)jObject["IS_READ"];
- status = (string)jObject["STATUS"];
- is_show = (string)jObject["IS_SHOW"];
- note = (string)jObject["NOTE"];
- }
- }
- //public RowStructure(IConfiguration configuration, JObject jObject, int type)
- //{
- // if (jObject != null)
- // {
- // if (type == UtilsController.Constant.DATA_TYPE_ONE)
- // {
- // id = (string)jObject["id"];
- // parent_id = (string)jObject["parent_id"];
- // sv_id = (string)jObject["service_id"];
- // code = (string)jObject["code"];
- // name = (string)jObject["name"];
- // name_global = (string)jObject["name_global"];
- // name_local = (string)jObject["name_local"];
- // description = (string)jObject["description"];
- // description_global = (string)jObject["description_global"];
- // description_local = (string)jObject["description_local"];
- // introduction = (string)jObject["introduction"];
- // introduction_global = (string)jObject["introduction_global"];
- // introduction_local = (string)jObject["introduction_local"];
- // level = (string)jObject["level"];
- // permission = (string)jObject["TYPE"];
- // icon = configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + (string)jObject["icon"];
- // logo = configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + (string)jObject["logo"];
- // realIcon = (string)jObject["icon"];
- // realLogo = (string)jObject["logo"];
- // content = (string)jObject["content"];
- // content_type = (string)jObject["content_type"];
- // from_date = (string)jObject["from_date"];
- // to_date = (string)jObject["to_date"];
- // created_date = (string)jObject["create_date"];
- // update_date = (string)jObject["update_date"];
- // province_id = (string)jObject["province_id"];
- // topic_id = (string)jObject["topic_id"];
- // is_read = (string)jObject["is_read"];
- // status = (string)jObject["status"];
- // is_show = (string)jObject["is_show"];
- // note = (string)jObject["note"];
- // }
- // }
- //}
- public object Clone()
- {
- return this.MemberwiseClone();
- }
- }
- public class RowStructures
- {
- public List<RowStructure> data { get; set; }
- public RowStructures() { }
- public RowStructures(IConfiguration configuration, string json) : this(configuration, JObject.Parse(json)) { }
- public RowStructures(IConfiguration configuration, JObject jObject)
- {
- if (jObject != null)
- {
- var list = jObject["listNews"];
- //var dataTypeOne = jObject["dataTypeOne"];
- if (list != null && list.HasValues)
- {
- data = new List<RowStructure>();
- JArray a = (JArray)list;
- foreach (JObject o in a.Children<JObject>())
- {
- data.Add(new RowStructure(configuration, o));
- }
- }
- //else if (dataTypeOne != null && dataTypeOne.HasValues)
- //{
- // data = new List<RowStructure>();
- // JArray a = (JArray)dataTypeOne;
- // foreach (JObject o in a.Children<JObject>())
- // {
- // data.Add(new RowStructure(configuration, o));
- // }
- //}
- }
- }
- }
- }
|