Ver código fonte

Resorts - consolidated Data

master
George Williams 4 anos atrás
pai
commit
1adc2b99b5

+ 70
- 1
UnivateProperties_API/Containers/Timeshare/ResortDisplay.cs Ver arquivo

@@ -1,4 +1,6 @@
1
-namespace UnivateProperties_API.Containers.Timeshare
1
+using System.Collections.Generic;
2
+
3
+namespace UnivateProperties_API.Containers.Timeshare
2 4
 {
3 5
     public class ResortDisplay
4 6
     {
@@ -7,4 +9,71 @@
7 9
         public string ResortImage { get; set; }
8 10
         public int WeeksAvailable { get; set; }
9 11
     }
12
+
13
+    public class ResortData : GoMeloResort
14
+    {
15
+        public string Layout { get; set; }
16
+        public string Description { get; set; }        
17
+        public List<string> Images { get; set; }
18
+    }
19
+
20
+    public class GoMeloResort
21
+    {
22
+        public int PrIdx { get; set; }
23
+        public string PrProductIndex { get; set; }
24
+        public string PrProdType { get; set; }
25
+        public string PrName { get; set; }
26
+        public string PrPostAdd1 { get; set; }
27
+        public Coords PrPostAdd2 { get; set; }
28
+        public string PrPostTown { get; set; }
29
+        public string PrPostCountry { get; set; }
30
+        public string PrPostCode { get; set; }
31
+        public string PrStreetAdd1 { get; set; }
32
+        public string PrStreetAdd2 { get; set; }
33
+        public string PrStreetTown { get; set; }
34
+        public string PrStreetCountry { get; set; }
35
+        public string PrStreetCode { get; set; }
36
+        public string PrLastDate { get; set; }
37
+        public string PrManager { get; set; }
38
+        public string PrReservations { get; set; }
39
+        public string PrStartDate { get; set; }
40
+        public string PrStartYear { get; set; }
41
+        public string PrEndDate { get; set; }
42
+        public string PrNoYears { get; set; }
43
+        public string PrIntervals { get; set; }
44
+        public int PrIntervalWe { get; set; }
45
+        public int PrIntervalMw { get; set; }
46
+        public string PrRegion { get; set; }
47
+        public string PrCity { get; set; }
48
+        public string PrProvince { get; set; }
49
+        public string PrCheckin { get; set; }
50
+        public string PrCheckout { get; set; }
51
+        public string PrCheckInDay { get; set; }
52
+        public string PrNotes { get; set; }
53
+        public string PrDirections { get; set; }
54
+        public string PrUnitFacilities { get; set; }
55
+        public string PrAttractions { get; set; }
56
+        public string PrAlerts { get; set; }
57
+        public string PrManaged { get; set; }
58
+        public string PrCountry { get; set; }
59
+        public string PrWww { get; set; }
60
+        public string PrManAgent { get; set; }
61
+        public string PrImagePath { get; set; }
62
+        public string PrRciaffiliated { get; set; }
63
+        public string PrSelfCatering { get; set; }
64
+        public string PrLatitude { get; set; }
65
+        public string PrLongitude { get; set; }
66
+        public string PrAirport { get; set; }
67
+        public int PrAirportDistance { get; set; }
68
+        public string PrStadium { get; set; }
69
+        public int PrStadiumDistance { get; set; }
70
+        public string PrWcCity { get; set; }
71
+        public int PrWcCityDistance { get; set; }
72
+    }
73
+
74
+    public class Coords
75
+    {
76
+        public string Lat { get; set; }
77
+        public string Long { get; set; }
78
+    }
10 79
 }

+ 6
- 0
UnivateProperties_API/Controllers/Timeshare/ResortController.cs Ver arquivo

@@ -37,5 +37,11 @@ namespace UnivateProperties_API.Controllers.Timeshare
37 37
         {
38 38
             return new OkObjectResult(_Repo.GetResortImages(code));
39 39
         }
40
+
41
+        [HttpGet("GetResortData/{code}")]
42
+        public IActionResult GetResortData(string code)
43
+        {
44
+            return new OkObjectResult(_Repo.GetResortData(code));
45
+        }
40 46
     }
41 47
 }

+ 1
- 1
UnivateProperties_API/Helpers/TenderWeeksHelper.cs Ver arquivo

@@ -56,5 +56,5 @@ namespace UnivateProperties_API.Helpers
56 56
         public string Town { get; set; }
57 57
         public string City { get; set; }
58 58
         public int Id { get; set; }
59
-    }
59
+    }    
60 60
 }

+ 3
- 0
UnivateProperties_API/Repository/Properties/UserDefinedGroupRepository.cs Ver arquivo

@@ -204,6 +204,9 @@ namespace UnivateProperties_API.Repository.Properties
204 204
 
205 205
         public List<Group> GetSavedList(int PropertyId)
206 206
         {
207
+            if (PropertyId == 0)
208
+                return null;
209
+
207 210
             var prop = dBContext.Properties.Include("PropertyType").Where(p => p.Id == PropertyId).FirstOrDefault();
208 211
             var all = GetFieldListByPropType(prop.PropertyType.PropertyUsageType);
209 212
 

+ 55
- 0
UnivateProperties_API/Repository/Timeshare/IResortRepository.cs Ver arquivo

@@ -15,6 +15,7 @@ namespace UnivateProperties_API.Repository.Timeshare
15 15
         List<ResortDisplay> GetResortsByRegion(string regionCode);
16 16
         string GetResortDescription(string resortCode);
17 17
         List<string> GetResortImages(string resortCode);
18
+        ResortData GetResortData(string resortCode);
18 19
     }
19 20
 
20 21
     public class ResortRepository : IResortRepository
@@ -151,5 +152,59 @@ namespace UnivateProperties_API.Repository.Timeshare
151 152
 
152 153
             return resorts.OrderBy(r => r.ResortCode).ToList();
153 154
         }
155
+
156
+        public ResortData GetResortData(string resortCode)
157
+        {             
158
+            #region Get Resort Data
159
+            var client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/{0}", resortCode))
160
+            {
161
+                Timeout = -1
162
+            };
163
+            var request = new RestRequest(Method.GET);
164
+            IRestResponse response = client.Execute(request);
165
+            ResortData data = JsonConvert.DeserializeObject<ResortData>(response.Content);
166
+            #endregion
167
+
168
+            #region Get Layout
169
+            client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/layout", resortCode))
170
+            {
171
+                Timeout = -1
172
+            };
173
+            request = new RestRequest(Method.GET);
174
+            response = client.Execute(request);
175
+            data.Layout = response.Content;
176
+            if (!string.IsNullOrEmpty(data.Layout))
177
+            {
178
+                data.Layout = "data:image/jpeg;base64," + data.Layout;
179
+            }
180
+            #endregion
181
+
182
+            #region GetImages
183
+            data.Images = GetResortImages(resortCode);
184
+            if (data.Images == null || data.Images.Count == 0)
185
+            {
186
+                data.Images = new List<string>();
187
+                int count = 1; 
188
+                while( count < 5)
189
+                {
190
+                    client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/image/{1}", resortCode, count))
191
+                    {
192
+                        Timeout = -1
193
+                    };
194
+                    request = new RestRequest(Method.GET);
195
+                    response = client.Execute(request);
196
+                    var img = string.Format("data:image/jpeg;base64,{0}", response.Content);
197
+                    data.Images.Add(img);
198
+                    count++;
199
+                }
200
+            }
201
+            #endregion
202
+
203
+            #region Get Description
204
+            data.Description = GetResortDescription(resortCode);            
205
+            #endregion
206
+
207
+            return data; 
208
+        }
154 209
     }
155 210
 }

Carregando…
Cancelar
Salvar