API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TenderWeeksHelper.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Newtonsoft.Json;
  2. using RestSharp;
  3. using System.Collections.Generic;
  4. namespace UnivateProperties_API.Helpers
  5. {
  6. public static class TenderWeeksHelper
  7. {
  8. public static List<UniPointResorts> UniResorts = new List<UniPointResorts>();
  9. public static string GetResortName(string Code)
  10. {
  11. if (UniResorts.Count == 0)
  12. {
  13. var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/")
  14. {
  15. Timeout = -1
  16. };
  17. var request = new RestRequest(Method.GET);
  18. IRestResponse response = client.Execute(request);
  19. UniResorts = JsonConvert.DeserializeObject<List<UniPointResorts>>(response.Content);
  20. }
  21. var resort = UniResorts.Find(x => x.ResortCode == Code);
  22. if (resort != null)
  23. return resort.ResortName;
  24. else
  25. return Code;
  26. }
  27. }
  28. public class UniPointResorts
  29. {
  30. public string ResortName { get; set; }
  31. public string ResortCode { get; set; }
  32. public string Town { get; set; }
  33. public string City { get; set; }
  34. public int Id { get; set; }
  35. }
  36. }