Kaynağa Gözat

Reloaded Brian's Changes

master
George Williams 2 yıl önce
ebeveyn
işleme
2ed89777dd
24 değiştirilmiş dosya ile 4149 ekleme ve 163 silme
  1. 5
    1
      UnivateProperties_API/Containers/Timeshare/Detailed/DetailedWeekDto.cs
  2. 5
    1
      UnivateProperties_API/Containers/Timeshare/RegionDto.cs
  3. 1
    0
      UnivateProperties_API/Containers/Timeshare/ResortDisplay.cs
  4. 3
    2
      UnivateProperties_API/Containers/Timeshare/ResortDto.cs
  5. 85
    80
      UnivateProperties_API/Containers/Timeshare/WeekDto.cs
  6. 1
    1
      UnivateProperties_API/Containers/Users/AgencyDto.cs
  7. 1
    0
      UnivateProperties_API/Context/DataContext.cs
  8. 4
    2
      UnivateProperties_API/Controllers/Communication/MailController.cs
  9. 4
    4
      UnivateProperties_API/Controllers/Users/RegisterController.cs
  10. 42
    2
      UnivateProperties_API/Helpers/TenderWeeksHelper.cs
  11. 1887
    0
      UnivateProperties_API/Migrations/20220714123442_MailSource.Designer.cs
  12. 35
    0
      UnivateProperties_API/Migrations/20220714123442_MailSource.cs
  13. 1899
    0
      UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.Designer.cs
  14. 44
    0
      UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.cs
  15. 33
    0
      UnivateProperties_API/Migrations/DataContextModelSnapshot.cs
  16. 6
    9
      UnivateProperties_API/Model/Communication/MailModel.cs
  17. 13
    0
      UnivateProperties_API/Model/Communication/MailSource.cs
  18. 1
    1
      UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs
  19. 2
    2
      UnivateProperties_API/Program.cs
  20. 8
    0
      UnivateProperties_API/Repository/Communication/MailRepository.cs
  21. 16
    14
      UnivateProperties_API/Repository/Timeshare/IResortRepository.cs
  22. 44
    32
      UnivateProperties_API/Repository/Timeshare/WeekRepository.cs
  23. 7
    10
      UnivateProperties_API/Repository/Users/RegisterRepository.cs
  24. 3
    2
      UnivateProperties_API/appsettings.json

+ 5
- 1
UnivateProperties_API/Containers/Timeshare/Detailed/DetailedWeekDto.cs Dosyayı Görüntüle

@@ -1,11 +1,14 @@
1 1
 using Abp.Extensions;
2 2
 using System;
3
+using UnivateProperties_API.Helpers;
3 4
 using UnivateProperties_API.Model.Timeshare;
4 5
 
5 6
 namespace UnivateProperties_API.Containers.Timeshare.Detailed
6 7
 {
7 8
     public class DetailedWeekDto
8 9
     {
10
+        int resortId;
11
+
9 12
         public DetailedWeekDto()
10 13
         {
11 14
             Owner = new DetailedOwner();
@@ -19,7 +22,8 @@ namespace UnivateProperties_API.Containers.Timeshare.Detailed
19 22
             AgencyId = week.AgencyId;
20 23
             OtherResort = week.OtherResort;
21 24
             OtherResortName = week.OtherResortName;
22
-            Resort = new ResortDto(week.ResortCode, week.ResortName);
25
+            resortId = int.Parse(TenderWeeksHelper.GetResortId(week.ResortName));
26
+            Resort = new ResortDto(resortId, week.ResortCode, week.ResortName);
23 27
             ResortCode = week.ResortCode;
24 28
             ResortName = week.ResortName;
25 29
             RegionId = week.RegionId;

+ 5
- 1
UnivateProperties_API/Containers/Timeshare/RegionDto.cs Dosyayı Görüntüle

@@ -1,10 +1,13 @@
1 1
 using System.Collections.Generic;
2 2
 using System.Linq;
3
+using UnivateProperties_API.Helpers;
3 4
 
4 5
 namespace UnivateProperties_API.Containers.Timeshare
5 6
 {
6 7
     public class RegionDto : IDisplay
7 8
     {
9
+        int resortId;
10
+
8 11
         public RegionDto()
9 12
         {
10 13
             Resorts = new List<ResortDto>();
@@ -43,7 +46,8 @@ namespace UnivateProperties_API.Containers.Timeshare
43 46
         {
44 47
             if (!Resorts.Any(x => x.ResortCode == resortCode))
45 48
             {
46
-                Resorts.Add(new ResortDto(resortCode, resortName));
49
+                resortId = int.Parse(TenderWeeksHelper.GetResortId(resortName));
50
+                Resorts.Add(new ResortDto(resortId, resortCode, resortName));
47 51
             }
48 52
         }
49 53
 

+ 1
- 0
UnivateProperties_API/Containers/Timeshare/ResortDisplay.cs Dosyayı Görüntüle

@@ -4,6 +4,7 @@ namespace UnivateProperties_API.Containers.Timeshare
4 4
 {
5 5
     public class ResortDisplay
6 6
     {
7
+        public string ResortId { get; set; }
7 8
         public string ResortCode { get; set; }
8 9
         public string ResortName { get; set; }
9 10
         public string ResortImage { get; set; }

+ 3
- 2
UnivateProperties_API/Containers/Timeshare/ResortDto.cs Dosyayı Görüntüle

@@ -7,12 +7,13 @@
7 7
 
8 8
         }
9 9
 
10
-        public ResortDto(string resortCode, string resortName)
10
+        public ResortDto(int resortId, string resortCode, string resortName)
11 11
         {
12
+            ResortId = resortId;
12 13
             ResortCode = resortCode;
13 14
             ResortName = resortName;
14 15
         }
15
-
16
+        public int ResortId { get; set; }
16 17
         public string ResortCode { get; set; }
17 18
         public string ResortName { get; set; }
18 19
         public int Available { get; set; }

+ 85
- 80
UnivateProperties_API/Containers/Timeshare/WeekDto.cs Dosyayı Görüntüle

@@ -10,6 +10,8 @@ namespace UnivateProperties_API.Containers.Timeshare
10 10
 {
11 11
     public class WeekDto : IDisplay
12 12
     {
13
+        int resortId;
14
+
13 15
         public WeekDto()
14 16
         {
15 17
 
@@ -17,85 +19,86 @@ namespace UnivateProperties_API.Containers.Timeshare
17 19
 
18 20
         public WeekDto(int id, string line)
19 21
         {
20
-            Id = id;
21
-            List<string> split = line.Split(",").ToList();
22
-            AgentAsRep = false;
23
-            Resort = new ResortDto(split[0].Trim(), TenderWeeksHelper.GetResortName(split[0].Trim()));
24
-            UnitNumber = split[1].Trim();
25
-            WeekNumber = split[2].Trim();
26
-            switch (split[8].Trim())
27
-            {
28
-                case "R":
29
-                    Season = "Red";
30
-                    break;
31
-                case "W":
32
-                    Season = "White";
33
-                    break;
34
-                case "B":
35
-                    Season = "Blue";
36
-                    break;
37
-                case "1":
38
-                    Season = "Peak 1";
39
-                    break;
40
-                case "2":
41
-                    Season = "Peak 2";
42
-                    break;
43
-                case "3":
44
-                    Season = "Peak 3";
45
-                    break;
46
-                case "4":
47
-                    Season = "Peak 4";
48
-                    break;
49
-                case "5":
50
-                    Season = "Peak 5";
51
-                    break;
52
-                default:
53
-                    Season = split[8].Trim();
54
-                    break;
55
-            }
56
-            var size = split[3].Trim();
57
-            if (size.Length == 3 && !size.ToLower().StartsWith('s'))
58
-            {
59
-                int.TryParse(size.Substring(0, 1), out int temp);
60
-                Bedrooms = temp.ToString();
61
-                int.TryParse(size.Substring(2, 1), out temp);
62
-                MaxSleep = temp;
63
-            }
64
-            bool currentYear = split[9].Trim() == "Y";
65
-            string amt = split[5].Trim();
66
-            amt = amt.Replace('.', ',');
67
-            if (double.TryParse(amt, out double dAmt))
68
-                LevyAmount = dAmt;
69
-            DateTime tempDate = MyCommon.GetDateFromString(currentYear ? split[6].Trim() : split[13].Trim());
70
-            if (tempDate != DateTime.MinValue)
71
-            {
72
-                ArrivalDate = tempDate;
73
-            }
74
-            tempDate = MyCommon.GetDateFromString(currentYear ? split[7].Trim() : split[14].Trim());
75
-            if (tempDate != DateTime.MinValue)
76
-            {
77
-                DepartureDate = tempDate;
78
-            }
79
-            Region = new RegionDto() { RegionCode = split[24].Trim() };
80
-            IsTender = true;
81
-            ReferedByAgent = false;
82
-            // F-Fixed T-Timeshare (Fixed Timeshare Week) 
83
-            //PML - Peak / Medium / Low Felxi
84
-            switch (split[25].Trim())
85
-            {
86
-                case "T":
87
-                case "F":
88
-                    WeekType = "Fixed";
89
-                    break;
90
-                case "P":
91
-                case "M":
92
-                case "L":
93
-                    WeekType = "Peak Flexi";
94
-                    break;
95
-                default:
96
-                    WeekType = "";
97
-                    break;
98
-            }
22
+                Id = id;
23
+                List<string> split = line.Split(",").ToList();
24
+                AgentAsRep = false;
25
+                resortId = int.Parse(TenderWeeksHelper.GetResortId(TenderWeeksHelper.GetResortName(split[0].Trim())));
26
+                Resort = new ResortDto(resortId, split[0].Trim(), TenderWeeksHelper.GetResortName(split[0].Trim()));
27
+                UnitNumber = split[1].Trim();
28
+                WeekNumber = split[2].Trim();
29
+                switch (split[8].Trim())
30
+                {
31
+                    case "R":
32
+                        Season = "Red";
33
+                        break;
34
+                    case "W":
35
+                        Season = "White";
36
+                        break;
37
+                    case "B":
38
+                        Season = "Blue";
39
+                        break;
40
+                    case "1":
41
+                        Season = "Peak 1";
42
+                        break;
43
+                    case "2":
44
+                        Season = "Peak 2";
45
+                        break;
46
+                    case "3":
47
+                        Season = "Peak 3";
48
+                        break;
49
+                    case "4":
50
+                        Season = "Peak 4";
51
+                        break;
52
+                    case "5":
53
+                        Season = "Peak 5";
54
+                        break;
55
+                    default:
56
+                        Season = split[8].Trim();
57
+                        break;
58
+                }
59
+                var size = split[3].Trim();
60
+                if (size.Length == 3 && !size.ToLower().StartsWith('s'))
61
+                {
62
+                    int.TryParse(size.Substring(0, 1), out int temp);
63
+                    Bedrooms = temp.ToString();
64
+                    int.TryParse(size.Substring(2, 1), out temp);
65
+                    MaxSleep = temp;
66
+                }
67
+                bool currentYear = split[9].Trim() == "Y";
68
+                string amt = split[5].Trim();
69
+                amt = amt.Replace('.', ',');
70
+                if (double.TryParse(amt, out double dAmt))
71
+                    LevyAmount = dAmt;
72
+                DateTime tempDate = MyCommon.GetDateFromString(currentYear ? split[6].Trim() : split[13].Trim());
73
+                if (tempDate != DateTime.MinValue)
74
+                {
75
+                    ArrivalDate = tempDate;
76
+                }
77
+                tempDate = MyCommon.GetDateFromString(currentYear ? split[7].Trim() : split[14].Trim());
78
+                if (tempDate != DateTime.MinValue)
79
+                {
80
+                    DepartureDate = tempDate;
81
+                }
82
+                Region = new RegionDto() { RegionCode = split[24].Trim() };
83
+                IsTender = true;
84
+                ReferedByAgent = false;
85
+                // F-Fixed T-Timeshare (Fixed Timeshare Week) 
86
+                //PML - Peak / Medium / Low Felxi
87
+                switch (split[25].Trim())
88
+                {
89
+                    case "T":
90
+                    case "F":
91
+                        WeekType = "Fixed";
92
+                        break;
93
+                    case "P":
94
+                    case "M":
95
+                    case "L":
96
+                        WeekType = "Peak Flexi";
97
+                        break;
98
+                    default:
99
+                        WeekType = "";
100
+                        break;
101
+                }
99 102
         }
100 103
 
101 104
         public WeekDto(TimeshareWeek week)
@@ -110,7 +113,9 @@ namespace UnivateProperties_API.Containers.Timeshare
110 113
             Owner = week.DisplayOwner;
111 114
             OwnerId = week.Owner.Id;
112 115
             UserId = week.Owner.UserId;
113
-            Resort = new ResortDto(week.ResortCode, week.ResortName);
116
+            resortId = int.Parse(TenderWeeksHelper.GetResortId(week.ResortName));
117
+            Resort = new ResortDto(resortId, week.ResortCode, week.ResortName);
118
+            Resort.ResortId = int.Parse(TenderWeeksHelper.GetResortId(week.ResortName));
114 119
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
115 120
             Season = week.Season;
116 121
             if (week.Status != null)

+ 1
- 1
UnivateProperties_API/Containers/Users/AgencyDto.cs Dosyayı Görüntüle

@@ -5,7 +5,7 @@
5 5
         public int Id { get; set; }
6 6
         public string Name { get; set; }
7 7
         public string EaabeffcNumber { get; set; }
8
-        public string RegNo { get; set; }
8
+        public string CompanyRegNumber { get; set; }
9 9
         public UserDto User { get; set; }
10 10
     }
11 11
 }

+ 1
- 0
UnivateProperties_API/Context/DataContext.cs Dosyayı Görüntüle

@@ -59,6 +59,7 @@ namespace UnivateProperties_API.Context
59 59
         public virtual DbSet<PlaceHolder> PlaceHolders { get; set; }
60 60
         public virtual DbSet<MailRecipient> MailRecipients { get; set; }
61 61
         public virtual DbSet<MailModel> CommunicationLog { get; set; }
62
+        public virtual DbSet<MailSource> MailSource { get; set; }
62 63
         #endregion Communication
63 64
 
64 65
         #region Property

+ 4
- 2
UnivateProperties_API/Controllers/Communication/MailController.cs Dosyayı Görüntüle

@@ -1,5 +1,7 @@
1 1
 using Microsoft.AspNetCore.Mvc;
2 2
 using RestSharp;
3
+using System;
4
+using UnivateProperties_API.Helpers;
3 5
 using UnivateProperties_API.Model.Communication;
4 6
 using UnivateProperties_API.Repository.Communication;
5 7
 
@@ -31,9 +33,9 @@ namespace UnivateProperties_API.Controllers.Communication
31 33
                 }
32 34
                 return new OkResult();
33 35
             }
34
-            catch
36
+            catch (Exception ex)
35 37
             {
36
-                return new BadRequestResult();
38
+                return BadRequest(new { message = ex.Message });
37 39
             }
38 40
         }
39 41
 

+ 4
- 4
UnivateProperties_API/Controllers/Users/RegisterController.cs Dosyayı Görüntüle

@@ -98,8 +98,8 @@ namespace UnivateProperties_API.Controllers.Users
98 98
             }
99 99
             catch (AppException ex)
100 100
             {
101
-                //return BadRequest(new { message = ex.Message });
102
-                return StatusCode(409, ex);
101
+                return BadRequest(new { message = ex.Message });
102
+                //return StatusCode(409, ex);
103 103
             }
104 104
         }
105 105
 
@@ -115,7 +115,7 @@ namespace UnivateProperties_API.Controllers.Users
115 115
             }
116 116
             catch(Exception ex)
117 117
             {
118
-                return BadRequest(new { message = ex.Message + " - " + ex.InnerException + " - " + ex.StackTrace });
118
+                return BadRequest(new { message = ex.Message });
119 119
             }
120 120
         }
121 121
 
@@ -133,7 +133,7 @@ namespace UnivateProperties_API.Controllers.Users
133 133
                 _Repo.CreateAgency(agency);
134 134
                 return Ok();
135 135
             }
136
-            catch (AppException ex)
136
+            catch (Exception ex)
137 137
             {
138 138
                 // return error message if there was an exception
139 139
                 return BadRequest(new { message = ex.Message });

+ 42
- 2
UnivateProperties_API/Helpers/TenderWeeksHelper.cs Dosyayı Görüntüle

@@ -12,7 +12,7 @@ namespace UnivateProperties_API.Helpers
12 12
         {
13 13
             if (UniResorts.Count == 0)
14 14
             {
15
-                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/")
15
+                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list?disabled=true")
16 16
                 {
17 17
                     Timeout = -1
18 18
                 };
@@ -28,11 +28,31 @@ namespace UnivateProperties_API.Helpers
28 28
                 return Code;
29 29
         }
30 30
 
31
+
31 32
         public static string GetResortCode(string Name)
32 33
         {
33 34
             if (UniResorts.Count == 0)
34 35
             {
35
-                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/")
36
+                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list?disabled=true")
37
+                {
38
+                    Timeout = -1
39
+                };
40
+                var request = new RestRequest(Method.GET);
41
+                IRestResponse response = client.Execute(request);
42
+                UniResorts = JsonConvert.DeserializeObject<List<UniPointResorts>>(response.Content);
43
+            }
44
+
45
+            var resort = UniResorts.Find(x => x.ResortName == Name);
46
+            if (resort != null)
47
+                return resort.ResortCode;
48
+            else
49
+                return "";
50
+        }
51
+        public static string GetResortId(string Name)
52
+        {
53
+            if (UniResorts.Count == 0)
54
+            {
55
+                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list?disabled=true")
36 56
                 {
37 57
                     Timeout = -1
38 58
                 };
@@ -42,6 +62,26 @@ namespace UnivateProperties_API.Helpers
42 62
             }
43 63
 
44 64
             var resort = UniResorts.Find(x => x.ResortName == Name);
65
+            if (resort != null)
66
+                return resort.Id.ToString();
67
+            else
68
+                return "";
69
+        }
70
+
71
+        public static string GetResortCodeById(int Id)
72
+        {
73
+            if (UniResorts.Count == 0)
74
+            {
75
+                var client = new RestClient("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list?disabled=true")
76
+                {
77
+                    Timeout = -1
78
+                };
79
+                var request = new RestRequest(Method.GET);
80
+                IRestResponse response = client.Execute(request);
81
+                UniResorts = JsonConvert.DeserializeObject<List<UniPointResorts>>(response.Content);
82
+            }
83
+
84
+            var resort = UniResorts.Find(x => x.Id == Id);
45 85
             if (resort != null)
46 86
                 return resort.ResortCode;
47 87
             else

+ 1887
- 0
UnivateProperties_API/Migrations/20220714123442_MailSource.Designer.cs
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 35
- 0
UnivateProperties_API/Migrations/20220714123442_MailSource.cs Dosyayı Görüntüle

@@ -0,0 +1,35 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore.Metadata;
3
+using Microsoft.EntityFrameworkCore.Migrations;
4
+
5
+namespace UnivateProperties_API.Migrations
6
+{
7
+    public partial class MailSource : Migration
8
+    {
9
+        protected override void Up(MigrationBuilder migrationBuilder)
10
+        {
11
+            migrationBuilder.CreateTable(
12
+                name: "MailSource",
13
+                columns: table => new
14
+                {
15
+                    Id = table.Column<int>(nullable: false)
16
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
17
+                    Created = table.Column<DateTime>(nullable: false),
18
+                    Modified = table.Column<DateTime>(nullable: false),
19
+                    ModifiedBy = table.Column<string>(nullable: true),
20
+                    IsDeleted = table.Column<bool>(nullable: false),
21
+                    Description = table.Column<string>(nullable: true)
22
+                },
23
+                constraints: table =>
24
+                {
25
+                    table.PrimaryKey("PK_MailSource", x => x.Id);
26
+                });
27
+        }
28
+
29
+        protected override void Down(MigrationBuilder migrationBuilder)
30
+        {
31
+            migrationBuilder.DropTable(
32
+                name: "MailSource");
33
+        }
34
+    }
35
+}

+ 1899
- 0
UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.Designer.cs
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 44
- 0
UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.cs Dosyayı Görüntüle

@@ -0,0 +1,44 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class MailSourceMailModel : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<int>(
10
+                name: "MailSourceId",
11
+                table: "CommunicationLog",
12
+                nullable: false,
13
+                defaultValue: 0);
14
+
15
+            migrationBuilder.CreateIndex(
16
+                name: "IX_CommunicationLog_MailSourceId",
17
+                table: "CommunicationLog",
18
+                column: "MailSourceId");
19
+
20
+            migrationBuilder.AddForeignKey(
21
+                name: "FK_CommunicationLog_MailSource_MailSourceId",
22
+                table: "CommunicationLog",
23
+                column: "MailSourceId",
24
+                principalTable: "MailSource",
25
+                principalColumn: "Id",
26
+                onDelete: ReferentialAction.Cascade);
27
+        }
28
+
29
+        protected override void Down(MigrationBuilder migrationBuilder)
30
+        {
31
+            migrationBuilder.DropForeignKey(
32
+                name: "FK_CommunicationLog_MailSource_MailSourceId",
33
+                table: "CommunicationLog");
34
+
35
+            migrationBuilder.DropIndex(
36
+                name: "IX_CommunicationLog_MailSourceId",
37
+                table: "CommunicationLog");
38
+
39
+            migrationBuilder.DropColumn(
40
+                name: "MailSourceId",
41
+                table: "CommunicationLog");
42
+        }
43
+    }
44
+}

+ 33
- 0
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs Dosyayı Görüntüle

@@ -316,6 +316,8 @@ namespace UnivateProperties_API.Migrations
316 316
 
317 317
                     b.Property<bool>("IsDeleted");
318 318
 
319
+                    b.Property<int>("MailSourceId");
320
+
319 321
                     b.Property<string>("Message");
320 322
 
321 323
                     b.Property<DateTime>("Modified");
@@ -332,6 +334,8 @@ namespace UnivateProperties_API.Migrations
332 334
 
333 335
                     b.HasKey("Id");
334 336
 
337
+                    b.HasIndex("MailSourceId");
338
+
335 339
                     b.ToTable("CommunicationLog");
336 340
                 });
337 341
 
@@ -360,6 +364,27 @@ namespace UnivateProperties_API.Migrations
360 364
                     b.ToTable("MailRecipients");
361 365
                 });
362 366
 
367
+            modelBuilder.Entity("UnivateProperties_API.Model.Communication.MailSource", b =>
368
+                {
369
+                    b.Property<int>("Id")
370
+                        .ValueGeneratedOnAdd()
371
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
372
+
373
+                    b.Property<DateTime>("Created");
374
+
375
+                    b.Property<string>("Description");
376
+
377
+                    b.Property<bool>("IsDeleted");
378
+
379
+                    b.Property<DateTime>("Modified");
380
+
381
+                    b.Property<string>("ModifiedBy");
382
+
383
+                    b.HasKey("Id");
384
+
385
+                    b.ToTable("MailSource");
386
+                });
387
+
363 388
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
364 389
                 {
365 390
                     b.Property<int>("Id")
@@ -1639,6 +1664,14 @@ namespace UnivateProperties_API.Migrations
1639 1664
                         .OnDelete(DeleteBehavior.Cascade);
1640 1665
                 });
1641 1666
 
1667
+            modelBuilder.Entity("UnivateProperties_API.Model.Communication.MailModel", b =>
1668
+                {
1669
+                    b.HasOne("UnivateProperties_API.Model.Communication.MailSource", "MailSource")
1670
+                        .WithMany("MailModels")
1671
+                        .HasForeignKey("MailSourceId")
1672
+                        .OnDelete(DeleteBehavior.Cascade);
1673
+                });
1674
+
1642 1675
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
1643 1676
                 {
1644 1677
                     b.HasOne("UnivateProperties_API.Model.Communication.Template", "Template")

+ 6
- 9
UnivateProperties_API/Model/Communication/MailModel.cs Dosyayı Görüntüle

@@ -1,24 +1,21 @@
1
-namespace UnivateProperties_API.Model.Communication
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+
3
+namespace UnivateProperties_API.Model.Communication
2 4
 {
3 5
     public class MailModel : BaseEntity
4 6
     {
5 7
         public string ComType { get; set; }
6 8
         public string ToAddress { get; set; }
7
-
8 9
         public string FromAddress { get; set; }
9
-
10 10
         public string Name { get; set; }
11
-
12 11
         public string Email { get; set; }
13
-
14 12
         public string Phone { get; set; }
15
-
16 13
         public string Property { get; set; }
17
-
18 14
         public string Message { get; set; }
19
-
20 15
         public string HeardFrom { get; set; }
21
-
16
+        [ForeignKey("MailSource")]
17
+        public int MailSourceId { get; set; }
18
+        public virtual MailSource MailSource { get; set; }
22 19
         public string Error { get; set; }
23 20
     }
24 21
 }

+ 13
- 0
UnivateProperties_API/Model/Communication/MailSource.cs Dosyayı Görüntüle

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace UnivateProperties_API.Model.Communication
7
+{
8
+    public class MailSource : BaseEntity
9
+    {
10
+        public string Description { get; set; }
11
+        public ICollection<MailModel> MailModels { get; set; }
12
+    }
13
+}

+ 1
- 1
UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs Dosyayı Görüntüle

@@ -14,7 +14,7 @@ namespace UnivateProperties_API.Model.Timeshare
14 14
         {
15 15
         }
16 16
 
17
-        public TimeshareWeek(bool referedByAgent, int? agentId, int? agencyId, int ownerId, bool agentAsRep, bool otherResort, string otherResortName, string resortCode, string resortName, int regionId, string season, string module, string bedrooms, int maxSleep, string unitNumber, string weekNumber, double levyAmount, bool currentYearBanked, string bankedWith, bool leviesPaidInFull, bool weekPlacedForRental, double originalPurchasePrice, DateTime originalPurchaseDate, DateTime arrivalDate, DateTime departureDate, double sellPrice, double askingPrice, double agentCommision, bool mandate, int statusId, Status status, Province region, Individual owner, Agent agent, Agency agency, ICollection<BidItem> bidItems, ICollection<ProcessFlow.ProcessFlow> processFlows, string weekStatus, DateTime datePublished, bool published, string displayOwner, bool customOwner)
17
+        public TimeshareWeek(bool referedByAgent, int? agentId, int? agencyId, int ownerId, bool agentAsRep, bool otherResort, string otherResortName, int resortId, string resortCode, string resortName, int regionId, string season, string module, string bedrooms, int maxSleep, string unitNumber, string weekNumber, double levyAmount, bool currentYearBanked, string bankedWith, bool leviesPaidInFull, bool weekPlacedForRental, double originalPurchasePrice, DateTime originalPurchaseDate, DateTime arrivalDate, DateTime departureDate, double sellPrice, double askingPrice, double agentCommision, bool mandate, int statusId, Status status, Province region, Individual owner, Agent agent, Agency agency, ICollection<BidItem> bidItems, ICollection<ProcessFlow.ProcessFlow> processFlows, string weekStatus, DateTime datePublished, bool published, string displayOwner, bool customOwner)
18 18
         {
19 19
             ReferedByAgent = referedByAgent;
20 20
             AgentId = agentId;

+ 2
- 2
UnivateProperties_API/Program.cs Dosyayı Görüntüle

@@ -18,8 +18,8 @@ namespace UnivateProperties_API
18 18
         public static IWebHost BuildWebHost(string[] args) =>
19 19
             WebHost.CreateDefaultBuilder(args)
20 20
                 .UseStartup<Startup>()
21
-                //.UseUrls("http://localhost:57260")
22
-                .UseUrls("http://training.provision-sa.com:82")
21
+                .UseUrls("http://localhost:57260")
22
+                //.UseUrls("http://training.provision-sa.com:82")
23 23
                 .UseIISIntegration()
24 24
                 .Build();
25 25
     }

+ 8
- 0
UnivateProperties_API/Repository/Communication/MailRepository.cs Dosyayı Görüntüle

@@ -101,6 +101,10 @@ namespace UnivateProperties_API.Repository.Communication
101 101
             mm.Error = error;
102 102
             _dbContext.CommunicationLog.Add(mm);
103 103
             _dbContext.SaveChanges();
104
+            if (error != "None")
105
+            {
106
+                throw new AppException("SMTP Server Error - Please try later.");
107
+            }
104 108
         }
105 109
 
106 110
         public void EnquireNow(MailModel mm)
@@ -166,6 +170,10 @@ namespace UnivateProperties_API.Repository.Communication
166 170
             mm.Error = error;
167 171
             _dbContext.CommunicationLog.Add(mm);
168 172
             _dbContext.SaveChanges();
173
+            if (error != "None")
174
+            {
175
+                throw new AppException("SMTP Server Error - Please try later.");
176
+            }
169 177
         }
170 178
 
171 179
         public void ForgotPassword(Individual toPerson, string link)

+ 16
- 14
UnivateProperties_API/Repository/Timeshare/IResortRepository.cs Dosyayı Görüntüle

@@ -29,7 +29,7 @@ namespace UnivateProperties_API.Repository.Timeshare
29 29
             _dbContext = dbContext;
30 30
         }
31 31
 
32
-        public string GetResortDescription(string resortCode)
32
+        public string GetResortDescription(string resortId)
33 33
         {
34 34
             var requestDataURL = MyCommon.Reservations.Replace("ReservationsWebService.asmx", "");
35 35
             var client = new RestClient(MyCommon.Reservations)
@@ -44,7 +44,7 @@ namespace UnivateProperties_API.Repository.Timeshare
44 44
                 , 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>"
45 45
                 , MyCommon.ReservationsUserCode
46 46
                 , MyCommon.ReservationsPassword
47
-                , resortCode
47
+                , resortId
48 48
                 , requestDataURL)
49 49
                 , ParameterType.RequestBody);
50 50
             IRestResponse response = client.Execute(request);           
@@ -107,6 +107,7 @@ namespace UnivateProperties_API.Repository.Timeshare
107 107
                 if (!resortNames.Contains(week.ResortName))
108 108
                 {
109 109
                     resortNames.Add(week.ResortName);
110
+                    resortObject.resortId = int.Parse(TenderWeeksHelper.GetResortId(week.ResortName));
110 111
                     resortObject.resortName = week.ResortName;
111 112
                     resortObject.resortCode = week.ResortCode;
112 113
                     resortObject.resortRegion = provinces.Where(p => p.Id == week.RegionId);
@@ -139,7 +140,7 @@ namespace UnivateProperties_API.Repository.Timeshare
139 140
             WeekRepository weekRepo = new WeekRepository(_dbContext);
140 141
             var weeks = weekRepo.GetDtoListAll();
141 142
 
142
-            var client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/{0}", regionCode))
143
+            var client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/{0}?disabled=true", regionCode))
143 144
             {
144 145
                 Timeout = -1
145 146
             };
@@ -149,18 +150,19 @@ namespace UnivateProperties_API.Repository.Timeshare
149 150
 
150 151
             foreach(var resort in UniResorts)
151 152
             {
152
-                if (!string.IsNullOrEmpty(resort.ResortCode))
153
-                {                   
153
+                //if (!string.IsNullOrEmpty(resort.ResortCode))
154
+                //{
154 155
                     ResortDisplay desp = new ResortDisplay()
155 156
                     {
157
+                        ResortId = resort.Id.ToString(),
156 158
                         ResortCode = resort.ResortCode,
157 159
                         ResortName = resort.ResortName
158 160
                     };
159 161
 
160
-                    var images = GetResortImages(resort.ResortCode);
162
+                    var images = GetResortImages(desp.ResortId);
161 163
                     if (images == null || images.Count == 0)
162 164
                     {
163
-                        var imgClient = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/image/0", resort.ResortCode))
165
+                        var imgClient = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/image/0", resort.Id))
164 166
                         {
165 167
                             Timeout = -1
166 168
                         };
@@ -178,16 +180,16 @@ namespace UnivateProperties_API.Repository.Timeshare
178 180
                     desp.WeeksAvailable = weeks.Where(w => w.Resort.ResortCode == resort.ResortCode).Where(x => x.Publish == true).Count();
179 181
 
180 182
                     resorts.Add(desp);
181
-                }
183
+                //}
182 184
             }
183 185
 
184 186
             return resorts.OrderBy(r => r.ResortCode).ToList();
185 187
         }
186 188
 
187
-        public ResortData GetResortData(string resortCode)
189
+        public ResortData GetResortData(string resortId)
188 190
         {             
189 191
             #region Get Resort Data
190
-            var client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/{0}", resortCode))
192
+            var client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/TRESORT/{0}", resortId))
191 193
             {
192 194
                 Timeout = -1
193 195
             };
@@ -197,7 +199,7 @@ namespace UnivateProperties_API.Repository.Timeshare
197 199
             #endregion
198 200
 
199 201
             #region Get Layout
200
-            client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/layout", resortCode))
202
+            client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/layout", resortId))
201 203
             {
202 204
                 Timeout = -1
203 205
             };
@@ -211,14 +213,14 @@ namespace UnivateProperties_API.Repository.Timeshare
211 213
             #endregion
212 214
 
213 215
             #region GetImages
214
-            data.Images = GetResortImages(resortCode);
216
+            data.Images = GetResortImages(resortId);
215 217
             if (data.Images == null || data.Images.Count == 0)
216 218
             {
217 219
                 data.Images = new List<string>();
218 220
                 int count = 0;
219 221
                 while (count < 5)
220 222
                 {
221
-                    client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/image/{1}", resortCode, count))
223
+                    client = new RestClient(string.Format("https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/{0}/image/{1}", resortId, count))
222 224
                     {
223 225
                         Timeout = -1
224 226
                     };
@@ -232,7 +234,7 @@ namespace UnivateProperties_API.Repository.Timeshare
232 234
 #endregion
233 235
 
234 236
             #region Get Description
235
-            data.Description = GetResortDescription(resortCode);            
237
+            data.Description = GetResortDescription(resortId);            
236 238
             #endregion
237 239
 
238 240
             return data; 

+ 44
- 32
UnivateProperties_API/Repository/Timeshare/WeekRepository.cs Dosyayı Görüntüle

@@ -2,6 +2,7 @@
2 2
 using Abp.Extensions;
3 3
 using Microsoft.CodeAnalysis;
4 4
 using Microsoft.EntityFrameworkCore;
5
+using Newtonsoft.Json;
5 6
 using RestSharp;
6 7
 using System;
7 8
 using System.Collections.Generic;
@@ -75,21 +76,22 @@ namespace UnivateProperties_API.Repository.Timeshare
75 76
             return null;
76 77
         }
77 78
 
78
-        public List<WeekDto> GetAllByResortCode(string resortCode) 
79
+        public List<WeekDto> GetAllByResortCode(string resortCode)
79 80
         {
80 81
             List<WeekDto> list = new List<WeekDto>();
81
-            foreach (var item in GetDetailedByResortCode(resortCode))
82
+            string resort;
83
+            resort = TenderWeeksHelper.GetResortCodeById(int.Parse(resortCode));
84
+            foreach (var item in GetDetailedByResortCode(resort))
82 85
             {
83 86
                 list.Add(new WeekDto(item));
84 87
             }
85 88
 
86 89
             var listIds = list.Select(x => x.WeekUni).ToList();
87
-
88
-            foreach (var item in GetTenderWeeksByResortCode(resortCode))
89
-            {
90
-                if (!listIds.Contains(item.WeekUni))
91
-                    list.Add(item);
92
-            }
90
+                foreach (var item in GetTenderWeeksByResortCode(resort))
91
+                {
92
+                    if (!listIds.Contains(item.WeekUni))
93
+                        list.Add(item);
94
+                }
93 95
             return list;
94 96
         }
95 97
 
@@ -103,7 +105,6 @@ namespace UnivateProperties_API.Repository.Timeshare
103 105
             }
104 106
             return weeklist;
105 107
         }
106
-
107 108
         private List<TimeshareWeek> GetAllUsingResortCode(string resortCode)
108 109
         {
109 110
             return _dbContext.Weeks.Where(x => x.ResortCode == resortCode).ToList();
@@ -259,7 +260,7 @@ namespace UnivateProperties_API.Repository.Timeshare
259 260
         {
260 261
             List<RegionDto> list = new List<RegionDto>();
261 262
             var allItems = GetDtoListAll();
262
-            foreach (var item in allItems)
263
+             foreach (var item in allItems)
263 264
             {
264 265
                 if (item.Region != null)
265 266
                 {
@@ -270,6 +271,7 @@ namespace UnivateProperties_API.Repository.Timeshare
270 271
                     foreach (var i in list.Where(x => x.RegionCode == item.Region.RegionCode))
271 272
                     {
272 273
                         i.TryAddResort(item.Resort.ResortCode, item.Resort.ResortName);
274
+                        
273 275
                     }
274 276
                 }
275 277
             }
@@ -280,11 +282,15 @@ namespace UnivateProperties_API.Repository.Timeshare
280 282
                 foreach (var resort in region.Resorts)
281 283
                 {
282 284
                     resort.Available = allItems.Count(x => x.Resort.ResortCode == resort.ResortCode);
285
+                    //resort.ResortId = int.Parse(TenderWeeksHelper.GetResortId(resort.ResortName));
283 286
                 }
284 287
             }
288
+
285 289
             return list;
286 290
         }
287 291
 
292
+
293
+
288 294
         public List<TimeshareWeek> GetDetailedAll()
289 295
         {
290 296
             var list = GetAll();
@@ -715,18 +721,21 @@ namespace UnivateProperties_API.Repository.Timeshare
715 721
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
716 722
             {
717 723
                 string result = reader.ReadToEnd();
718
-
719
-                if (result.Length > 0)
724
+                result = result.Replace("\n", "").Trim();
725
+                if (result != "Resort Error")
720 726
                 {
721
-                    string cleanLine;
722
-                    string[] lines = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
723
-                    foreach (string line in lines)
727
+                    if (result.Length > 0)
724 728
                     {
725
-                        cleanLine = line.Replace("<br>", "");
726
-                        cleanLine = cleanLine.Replace("<br >", "");
727
-                        cleanLine = cleanLine.Replace("<br/>", "");
728
-                        cleanLine = cleanLine.Replace("<br />", "");
729
-                        list.Add(new WeekDto(GetTenderId(),cleanLine));
729
+                        string cleanLine;
730
+                        string[] lines = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
731
+                        foreach (string line in lines)
732
+                        {
733
+                            cleanLine = line.Replace("<br>", "");
734
+                            cleanLine = cleanLine.Replace("<br >", "");
735
+                            cleanLine = cleanLine.Replace("<br/>", "");
736
+                            cleanLine = cleanLine.Replace("<br />", "");
737
+                            list.Add(new WeekDto(GetTenderId(), cleanLine));
738
+                        }
730 739
                     }
731 740
                 }
732 741
             }
@@ -749,23 +758,26 @@ namespace UnivateProperties_API.Repository.Timeshare
749 758
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
750 759
             {
751 760
                 string result = reader.ReadToEnd();
752
-
753
-                if (result.Length > 0)
761
+                result = result.Replace("\n", "").Trim();
762
+                if (result != "Resort Error")
754 763
                 {
755
-                    string cleanLine;
756
-                    string[] lines = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
757
-                    if (lines[0].Trim() != "none")
764
+                    if (result.Length > 0)
758 765
                     {
759
-                        foreach (string line in lines)
766
+                        string cleanLine;
767
+                        string[] lines = result.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
768
+                        if (lines[0].Trim() != "none")
760 769
                         {
761
-                            cleanLine = line.Replace("<br>", "");
762
-                            cleanLine = cleanLine.Replace("<br >", "");
763
-                            cleanLine = cleanLine.Replace("<br/>", "");
764
-                            cleanLine = cleanLine.Replace("<br />", "");
765
-                            list.Add(new WeekDto(GetTenderId(), cleanLine));
770
+                            foreach (string line in lines)
771
+                            {
772
+                                cleanLine = line.Replace("<br>", "");
773
+                                cleanLine = cleanLine.Replace("<br >", "");
774
+                                cleanLine = cleanLine.Replace("<br/>", "");
775
+                                cleanLine = cleanLine.Replace("<br />", "");
776
+                                list.Add(new WeekDto(GetTenderId(), cleanLine));
777
+                            }
766 778
                         }
779
+
767 780
                     }
768
-                    
769 781
                 }
770 782
             }
771 783
             // Check that all regions are same as other

+ 7
- 10
UnivateProperties_API/Repository/Users/RegisterRepository.cs Dosyayı Görüntüle

@@ -71,11 +71,6 @@ namespace UnivateProperties_API.Repository.Users
71 71
         public Agency CreateAgency(AgencyDto agency)
72 72
         {
73 73
             // validation
74
-            /* if (string.IsNullOrWhiteSpace(agency.EaabeffcNumber))
75
-                 throw new AppException("eaabeffcNumber is required");
76
-
77
-             if (_dbContext.Agencies.Any(x => x.EAABEFFCNumber == agency.EaabeffcNumber))
78
-                 throw new AppException("eaabeffcNumber \"" + agency.EaabeffcNumber + "\" already exists");*/
79 74
             if (!string.IsNullOrEmpty(agency.EaabeffcNumber))
80 75
             {
81 76
                 var savedAgency = _dbContext.Agencies.Where(x => x.EAABEFFCNumber == agency.EaabeffcNumber).FirstOrDefault();
@@ -85,12 +80,11 @@ namespace UnivateProperties_API.Repository.Users
85 80
                     {
86 81
                         AgencyName = agency.Name,
87 82
                         EAABEFFCNumber = agency.EaabeffcNumber,
88
-                        CompanyRegNumber = agency.RegNo
83
+                        CompanyRegNumber = agency.CompanyRegNumber
89 84
                     };
90 85
                     _dbContext.Agencies.Add(a);
91 86
                     CreatePerson(agency.User, PersonType.Agent, false, a);
92
-
93
-
87
+                    _dbContext.SaveChanges();
94 88
                     return a;
95 89
                 }
96 90
                 else
@@ -99,6 +93,7 @@ namespace UnivateProperties_API.Repository.Users
99 93
                     _dbContext.SaveChanges();
100 94
                     return savedAgency;
101 95
                 }
96
+
102 97
             }
103 98
             else 
104 99
             {
@@ -115,7 +110,9 @@ namespace UnivateProperties_API.Repository.Users
115 110
                 throw new AppException("Password is required");
116 111
 
117 112
             if (_dbContext.Users.Any(x => x.Username == individual.Username))
118
-                throw new AppException("Individual \"" + individual.Username + "\" is already taken");
113
+                throw new AppException("Username \"" + individual.Username + "\" is already taken");
114
+            if (_dbContext.Individuals.Any(x => x.Email == individual.Email))
115
+                throw new AppException("Email \"" + individual.Email + "\" is already taken");
119 116
 
120 117
             MyCommon.CreatePasswordHash(individual.Password, out byte[] passwordHash, out byte[] passwordSalt);
121 118
 
@@ -438,7 +435,7 @@ namespace UnivateProperties_API.Repository.Users
438 435
             }
439 436
             else
440 437
             {
441
-                throw new Exception();
438
+                throw new AppException("Email address not found!");
442 439
             }
443 440
         }
444 441
 

+ 3
- 2
UnivateProperties_API/appsettings.json Dosyayı Görüntüle

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

Loading…
İptal
Kaydet