Province.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. namespace SuperAdmin.Models.Object
  7. {
  8. public class Province
  9. {
  10. public String id { get; set; }
  11. public String name { get; set; }
  12. public String code { get; set; }
  13. public Province(string id, string name, string code)
  14. {
  15. this.id = id;
  16. this.name = name;
  17. this.code = code;
  18. }
  19. public Province() { }
  20. public Province(string json) : this(JObject.Parse(json))
  21. { }
  22. public Province(JObject jObject)
  23. {
  24. if (jObject != null)
  25. {
  26. id = (string)jObject["id"];
  27. name = (string)jObject["name"];
  28. code = (string)jObject["code"];
  29. }
  30. }
  31. }
  32. public class Provinces
  33. {
  34. public List<Province> data { get; set; }
  35. public Provinces() { }
  36. public Provinces(string json) : this(JObject.Parse(json)) { }
  37. public Provinces(JObject jObject)
  38. {
  39. if (jObject != null)
  40. {
  41. var list = jObject["listProvice"];
  42. if (list != null && list.HasValues)
  43. {
  44. data = new List<Province>();
  45. JArray a = (JArray)list;
  46. foreach (JObject o in a.Children<JObject>())
  47. {
  48. data.Add(new Province(o));
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }