소스 검색

Update

master
30117125 4 년 전
부모
커밋
f2f09fb19c

+ 12
- 0
UnivateProperties_API/Controllers/Timeshare/ResortController.cs 파일 보기

@@ -25,5 +25,17 @@ namespace UnivateProperties_API.Controllers.Timeshare
25 25
         {
26 26
             return new OkObjectResult(_Repo.GetResortsByRegion(regionCode));
27 27
         }
28
+
29
+        [HttpGet("GetResortDescription/{code}")]
30
+        public IActionResult GetResortDescription(string code)
31
+        {
32
+            return new OkObjectResult(_Repo.GetResortDescription(code));
33
+        }
34
+
35
+        [HttpGet("GetResortImages/{code}")]
36
+        public IActionResult GetResortImages(string code)
37
+        {
38
+            return new OkObjectResult(_Repo.GetResortImages(code));
39
+        }
28 40
     }
29 41
 }

+ 1
- 1
UnivateProperties_API/Controllers/Timeshare/TimeshareWeekController.cs 파일 보기

@@ -91,7 +91,7 @@ namespace UnivateProperties_API.Controllers.Timeshare
91 91
             }
92 92
         }
93 93
 
94
-        [HttpPut("{id}")]
94
+        [HttpPut]
95 95
         public IActionResult Put([FromBody] TimeshareWeek item)
96 96
         {
97 97
             if (item != null)

+ 3
- 0
UnivateProperties_API/Helpers/MyCommon.cs 파일 보기

@@ -45,6 +45,9 @@ namespace UnivateProperties_API.Helpers
45 45
         }
46 46
 
47 47
         public static string TenderUrl { get; set; }
48
+        public static string Reservations { get; set; }
49
+        public static string ReservationsUserCode { get; set; }
50
+        public static string ReservationsPassword { get; set; }
48 51
 
49 52
         public static DateTime GetDateFromString(string value)
50 53
         {

+ 17
- 21
UnivateProperties_API/Repository/Properties/PropertyRepository.cs 파일 보기

@@ -114,22 +114,18 @@ namespace UnivateProperties_API.Repository.Properties
114 114
 
115 115
                         foreach (var val in groupFields)
116 116
                         {
117
-                            var item = new PropertyDetail()
117
+                            if (!string.IsNullOrEmpty(val.Value))
118 118
                             {
119
-                                Name = val.FieldName,
120
-                                Description = val.Description
121
-                            };
122
-
123
-                            detailGroup.Values.Add(item);
124
-
125
-                            if (!string.IsNullOrEmpty(val.Value) && (val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
126
-                            {
127
-                                item.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
119
+                                var item = new PropertyDetail()
120
+                                {
121
+                                    Name = val.FieldName,
122
+                                    Description = val.Description,
123
+                                    Value = val.Value
124
+                                };
125
+
126
+                                detailGroup.Values.Add(item);
128 127
                             }
129
-                            else
130
-                                item.Value = val.Value;
131 128
                         }
132
-
133 129
                         property.DisplayData.Add(detailGroup);
134 130
                     }
135 131
                 }
@@ -592,10 +588,10 @@ namespace UnivateProperties_API.Repository.Properties
592 588
                     display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
593 589
                 }
594 590
 
595
-                if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
596
-                {
597
-                    display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
598
-                }
591
+                //if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
592
+                //{
593
+                //    display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
594
+                //}
599 595
 
600 596
                 if (display.HasPendingOffer)
601 597
                     display.Available = "Offer Pending";
@@ -702,10 +698,10 @@ namespace UnivateProperties_API.Repository.Properties
702 698
                              && f.FieldName == "Floor Size"
703 699
                              select u.Value).FirstOrDefault();
704 700
 
705
-                if (!string.IsNullOrEmpty(prop.Size) && prop.Size.EndsWith("2"))
706
-                {
707
-                    prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
708
-                }
701
+                //if (!string.IsNullOrEmpty(prop.Size) && prop.Size.EndsWith("2"))
702
+                //{
703
+                //    prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
704
+                //}
709 705
 
710 706
                 prop.UsageType = (dBContext.PropertyTypes.Find(p.PropertyTypeId).UsageType == PropertyUsageType.Residential ? "Residential" : "Commercial");
711 707
                 prop.SaleType = p.IsSale ? "Sale" : "Rental";

+ 86
- 3
UnivateProperties_API/Repository/Timeshare/IResortRepository.cs 파일 보기

@@ -1,10 +1,9 @@
1 1
 using Newtonsoft.Json;
2 2
 using RestSharp;
3
-using System;
4 3
 using System.Collections.Generic;
4
+using System.Data;
5
+using System.IO;
5 6
 using System.Linq;
6
-using System.Security.Cryptography;
7
-using System.Threading.Tasks;
8 7
 using UnivateProperties_API.Containers.Timeshare;
9 8
 using UnivateProperties_API.Context;
10 9
 using UnivateProperties_API.Helpers;
@@ -14,6 +13,8 @@ namespace UnivateProperties_API.Repository.Timeshare
14 13
     public interface IResortRepository
15 14
     {
16 15
         List<ResortDisplay> GetResortsByRegion(string regionCode);
16
+        string GetResortDescription(string resortCode);
17
+        List<string> GetResortImages(string resortCode);
17 18
     }
18 19
 
19 20
     public class ResortRepository : IResortRepository
@@ -25,6 +26,88 @@ namespace UnivateProperties_API.Repository.Timeshare
25 26
             _dbContext = dbContext;
26 27
         }
27 28
 
29
+        public string GetResortDescription(string resortCode)
30
+        {
31
+            var requestDataURL = MyCommon.Reservations.Replace("ReservationsWebService.asmx", "");
32
+            var client = new RestClient(MyCommon.Reservations)
33
+            {
34
+                Timeout = -1
35
+            };
36
+            var request = new RestRequest(Method.POST);
37
+            request.AddHeader("charset", "utf-8");
38
+            request.AddHeader("Content-Type", "text/xml");
39
+            request.AddHeader("Cookie", "ASP.NET_SessionId=bis4e2xtmqjdvh2wlqfolzbt");
40
+            request.AddParameter("text/xml"
41
+                , string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n  <soap:Body>\r\n    <GetResortDescription xmlns=\"{3}\">\r\n      <UserCode>{0}</UserCode>\r\n      <Password>{1}</Password>\r\n      <ResortCode>{2}</ResortCode>\r\n    </GetResortDescription>\r\n  </soap:Body>\r\n</soap:Envelope>"
42
+                , MyCommon.ReservationsUserCode
43
+                , MyCommon.ReservationsPassword
44
+                , resortCode
45
+                , requestDataURL)
46
+                , ParameterType.RequestBody);
47
+            IRestResponse response = client.Execute(request);           
48
+
49
+            string description = "";
50
+            if (!string.IsNullOrEmpty(response.Content) && !response.Content.Contains("ERROR:"))
51
+            {
52
+                DataSet data = CreateDataSet(response.Content);
53
+                if (data.Tables.Count > 1)
54
+                {
55
+                    foreach (DataRow row in data.Tables["GetResortDescriptionResponse"].Rows)
56
+                        description = row[0].ToString();
57
+                }
58
+            }
59
+            return description;
60
+        }
61
+
62
+        public List<string> GetResortImages(string resortCode)
63
+        {
64
+            var requestDataURL = MyCommon.Reservations.Replace("ReservationsWebService.asmx", "");
65
+            var client = new RestClient(MyCommon.Reservations)
66
+            {
67
+                Timeout = -1
68
+            };
69
+            var request = new RestRequest(Method.POST);
70
+            request.AddHeader("charset", "utf-8");
71
+            request.AddHeader("Content-Type", "text/xml");
72
+            request.AddHeader("Cookie", "ASP.NET_SessionId=bis4e2xtmqjdvh2wlqfolzbt");
73
+            request.AddParameter("text/xml"
74
+                , string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n  <soap:Body>\r\n    <GetResortImages  xmlns=\"{3}\">\r\n      <UserCode>{0}</UserCode>\r\n      <Password>{1}</Password>\r\n      <ResortCode>{2}</ResortCode>\r\n    </GetResortImages >\r\n  </soap:Body>\r\n</soap:Envelope>"
75
+                , MyCommon.ReservationsUserCode
76
+                , MyCommon.ReservationsPassword
77
+                , resortCode
78
+                , requestDataURL)
79
+                , ParameterType.RequestBody);
80
+            IRestResponse response = client.Execute(request);            
81
+
82
+            var images = new List<string>();
83
+            if (!string.IsNullOrEmpty(response.Content) && !response.Content.Contains("ERROR:"))
84
+            {
85
+                DataSet data = CreateDataSet(response.Content);
86
+                if (data.Tables.Count > 1)
87
+                {
88
+                    foreach (DataRow row in data.Tables["string"].Rows)
89
+                        images.Add(row[0].ToString());
90
+                }
91
+            }
92
+            return images;
93
+        }
94
+
95
+        public DataSet CreateDataSet(string data)
96
+        {
97
+            try
98
+            {
99
+                StringReader theReader = new StringReader(data);
100
+                DataSet theDataSet = new DataSet();
101
+                theDataSet.ReadXml(theReader);
102
+
103
+                return theDataSet;
104
+            }
105
+            catch
106
+            {
107
+                return null;
108
+            }
109
+        }
110
+
28 111
         public List<ResortDisplay> GetResortsByRegion(string regionCode)
29 112
         {
30 113
             var resorts = new List<ResortDisplay>();

+ 3
- 0
UnivateProperties_API/Startup.cs 파일 보기

@@ -59,6 +59,9 @@ namespace UnivateProperties_API
59 59
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
60 60
             services.AddDbContext<DataContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
61 61
             MyCommon.TenderUrl = Configuration.GetConnectionString("TenderConnection");
62
+            MyCommon.Reservations = Configuration.GetConnectionString("ReservationsURL");
63
+            MyCommon.ReservationsUserCode = Configuration.GetConnectionString("ReservationsUserCode");
64
+            MyCommon.ReservationsPassword = Configuration.GetConnectionString("ReservationsPassword");
62 65
 
63 66
             var appSettingsSection = Configuration.GetSection("AppSettings");
64 67
             services.Configure<AppSettings>(appSettingsSection);

+ 5
- 2
UnivateProperties_API/appsettings.json 파일 보기

@@ -9,7 +9,10 @@
9 9
   },
10 10
   "AllowedHosts": "*",
11 11
   "ConnectionStrings": {
12
-    "DefaultConnection": "Data Source=192.168.0.219;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
13
-    "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N"
12
+    "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
13
+    "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",
14
+    "ReservationsURL": "http://training.provision-sa.com:84/ReservationsWebService.asmx", //Please note that ReservationsWebService must be in this case. 
15
+    "ReservationsUserCode": "UniInt",
16
+    "ReservationsPassword": "Un11nt"
14 17
   }
15 18
 }

Loading…
취소
저장