ConnTelco.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. namespace SuperCms.Models
  8. {
  9. public class ConnTelco
  10. {
  11. public String id { get; set; }
  12. public String telcoCode { get; set; }
  13. public String telcoName { get; set; }
  14. public String sequence { get; set; }
  15. public String timeDiff { get; set; }
  16. public override string ToString()
  17. {
  18. return JsonConvert.SerializeObject(this);
  19. }
  20. public ConnTelco() { }
  21. public ConnTelco(string json) : this(JObject.Parse(json))
  22. { }
  23. public ConnTelco(JObject jObject)
  24. {
  25. if (jObject != null)
  26. {
  27. id = (string)jObject["ID"];
  28. telcoCode = (string)jObject["TELCO_CODE"];
  29. telcoName = (string)jObject["TELCO_NAME"];
  30. sequence = (string)jObject["SEQUENCE"];
  31. timeDiff = (string)jObject["TIME_DIFF"];
  32. }
  33. }
  34. }
  35. public class ConnTelcos
  36. {
  37. [JsonProperty("data")]
  38. public List<ConnTelco> data { get; set; }
  39. public override string ToString()
  40. {
  41. return JsonConvert.SerializeObject(this);
  42. }
  43. public ConnTelcos() { }
  44. public ConnTelcos(string json) : this(JObject.Parse(json)) { }
  45. public ConnTelcos(JObject jObject)
  46. {
  47. if (jObject != null)
  48. {
  49. var list = jObject["data"];
  50. if (list != null && list.HasValues)
  51. {
  52. data = new List<ConnTelco>();
  53. JArray a = (JArray)list;
  54. foreach (JObject o in a.Children<JObject>())
  55. {
  56. data.Add(new ConnTelco(o));
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }