Browse Source

Reloaded Brian's Changes

master
George Williams 2 years ago
parent
commit
2ed89777dd
24 changed files with 4149 additions and 163 deletions
  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 View File

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

+ 5
- 1
UnivateProperties_API/Containers/Timeshare/RegionDto.cs View File

1
 using System.Collections.Generic;
1
 using System.Collections.Generic;
2
 using System.Linq;
2
 using System.Linq;
3
+using UnivateProperties_API.Helpers;
3
 
4
 
4
 namespace UnivateProperties_API.Containers.Timeshare
5
 namespace UnivateProperties_API.Containers.Timeshare
5
 {
6
 {
6
     public class RegionDto : IDisplay
7
     public class RegionDto : IDisplay
7
     {
8
     {
9
+        int resortId;
10
+
8
         public RegionDto()
11
         public RegionDto()
9
         {
12
         {
10
             Resorts = new List<ResortDto>();
13
             Resorts = new List<ResortDto>();
43
         {
46
         {
44
             if (!Resorts.Any(x => x.ResortCode == resortCode))
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 View File

4
 {
4
 {
5
     public class ResortDisplay
5
     public class ResortDisplay
6
     {
6
     {
7
+        public string ResortId { get; set; }
7
         public string ResortCode { get; set; }
8
         public string ResortCode { get; set; }
8
         public string ResortName { get; set; }
9
         public string ResortName { get; set; }
9
         public string ResortImage { get; set; }
10
         public string ResortImage { get; set; }

+ 3
- 2
UnivateProperties_API/Containers/Timeshare/ResortDto.cs View File

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
             ResortCode = resortCode;
13
             ResortCode = resortCode;
13
             ResortName = resortName;
14
             ResortName = resortName;
14
         }
15
         }
15
-
16
+        public int ResortId { get; set; }
16
         public string ResortCode { get; set; }
17
         public string ResortCode { get; set; }
17
         public string ResortName { get; set; }
18
         public string ResortName { get; set; }
18
         public int Available { get; set; }
19
         public int Available { get; set; }

+ 85
- 80
UnivateProperties_API/Containers/Timeshare/WeekDto.cs View File

10
 {
10
 {
11
     public class WeekDto : IDisplay
11
     public class WeekDto : IDisplay
12
     {
12
     {
13
+        int resortId;
14
+
13
         public WeekDto()
15
         public WeekDto()
14
         {
16
         {
15
 
17
 
17
 
19
 
18
         public WeekDto(int id, string line)
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
         public WeekDto(TimeshareWeek week)
104
         public WeekDto(TimeshareWeek week)
110
             Owner = week.DisplayOwner;
113
             Owner = week.DisplayOwner;
111
             OwnerId = week.Owner.Id;
114
             OwnerId = week.Owner.Id;
112
             UserId = week.Owner.UserId;
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
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
119
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
115
             Season = week.Season;
120
             Season = week.Season;
116
             if (week.Status != null)
121
             if (week.Status != null)

+ 1
- 1
UnivateProperties_API/Containers/Users/AgencyDto.cs View File

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

+ 1
- 0
UnivateProperties_API/Context/DataContext.cs View File

59
         public virtual DbSet<PlaceHolder> PlaceHolders { get; set; }
59
         public virtual DbSet<PlaceHolder> PlaceHolders { get; set; }
60
         public virtual DbSet<MailRecipient> MailRecipients { get; set; }
60
         public virtual DbSet<MailRecipient> MailRecipients { get; set; }
61
         public virtual DbSet<MailModel> CommunicationLog { get; set; }
61
         public virtual DbSet<MailModel> CommunicationLog { get; set; }
62
+        public virtual DbSet<MailSource> MailSource { get; set; }
62
         #endregion Communication
63
         #endregion Communication
63
 
64
 
64
         #region Property
65
         #region Property

+ 4
- 2
UnivateProperties_API/Controllers/Communication/MailController.cs View File

1
 using Microsoft.AspNetCore.Mvc;
1
 using Microsoft.AspNetCore.Mvc;
2
 using RestSharp;
2
 using RestSharp;
3
+using System;
4
+using UnivateProperties_API.Helpers;
3
 using UnivateProperties_API.Model.Communication;
5
 using UnivateProperties_API.Model.Communication;
4
 using UnivateProperties_API.Repository.Communication;
6
 using UnivateProperties_API.Repository.Communication;
5
 
7
 
31
                 }
33
                 }
32
                 return new OkResult();
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 View File

98
             }
98
             }
99
             catch (AppException ex)
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
             }
115
             }
116
             catch(Exception ex)
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
                 _Repo.CreateAgency(agency);
133
                 _Repo.CreateAgency(agency);
134
                 return Ok();
134
                 return Ok();
135
             }
135
             }
136
-            catch (AppException ex)
136
+            catch (Exception ex)
137
             {
137
             {
138
                 // return error message if there was an exception
138
                 // return error message if there was an exception
139
                 return BadRequest(new { message = ex.Message });
139
                 return BadRequest(new { message = ex.Message });

+ 42
- 2
UnivateProperties_API/Helpers/TenderWeeksHelper.cs View File

12
         {
12
         {
13
             if (UniResorts.Count == 0)
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
                     Timeout = -1
17
                     Timeout = -1
18
                 };
18
                 };
28
                 return Code;
28
                 return Code;
29
         }
29
         }
30
 
30
 
31
+
31
         public static string GetResortCode(string Name)
32
         public static string GetResortCode(string Name)
32
         {
33
         {
33
             if (UniResorts.Count == 0)
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
                     Timeout = -1
57
                     Timeout = -1
38
                 };
58
                 };
42
             }
62
             }
43
 
63
 
44
             var resort = UniResorts.Find(x => x.ResortName == Name);
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
             if (resort != null)
85
             if (resort != null)
46
                 return resort.ResortCode;
86
                 return resort.ResortCode;
47
             else
87
             else

+ 1887
- 0
UnivateProperties_API/Migrations/20220714123442_MailSource.Designer.cs
File diff suppressed because it is too large
View File


+ 35
- 0
UnivateProperties_API/Migrations/20220714123442_MailSource.cs View File

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
File diff suppressed because it is too large
View File


+ 44
- 0
UnivateProperties_API/Migrations/20220714125536_MailSource-MailModel.cs View File

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 View File

316
 
316
 
317
                     b.Property<bool>("IsDeleted");
317
                     b.Property<bool>("IsDeleted");
318
 
318
 
319
+                    b.Property<int>("MailSourceId");
320
+
319
                     b.Property<string>("Message");
321
                     b.Property<string>("Message");
320
 
322
 
321
                     b.Property<DateTime>("Modified");
323
                     b.Property<DateTime>("Modified");
332
 
334
 
333
                     b.HasKey("Id");
335
                     b.HasKey("Id");
334
 
336
 
337
+                    b.HasIndex("MailSourceId");
338
+
335
                     b.ToTable("CommunicationLog");
339
                     b.ToTable("CommunicationLog");
336
                 });
340
                 });
337
 
341
 
360
                     b.ToTable("MailRecipients");
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
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
388
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
364
                 {
389
                 {
365
                     b.Property<int>("Id")
390
                     b.Property<int>("Id")
1639
                         .OnDelete(DeleteBehavior.Cascade);
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
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
1675
             modelBuilder.Entity("UnivateProperties_API.Model.Communication.PlaceHolder", b =>
1643
                 {
1676
                 {
1644
                     b.HasOne("UnivateProperties_API.Model.Communication.Template", "Template")
1677
                     b.HasOne("UnivateProperties_API.Model.Communication.Template", "Template")

+ 6
- 9
UnivateProperties_API/Model/Communication/MailModel.cs View File

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

+ 13
- 0
UnivateProperties_API/Model/Communication/MailSource.cs View File

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 View File

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
             ReferedByAgent = referedByAgent;
19
             ReferedByAgent = referedByAgent;
20
             AgentId = agentId;
20
             AgentId = agentId;

+ 2
- 2
UnivateProperties_API/Program.cs View File

18
         public static IWebHost BuildWebHost(string[] args) =>
18
         public static IWebHost BuildWebHost(string[] args) =>
19
             WebHost.CreateDefaultBuilder(args)
19
             WebHost.CreateDefaultBuilder(args)
20
                 .UseStartup<Startup>()
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
                 .UseIISIntegration()
23
                 .UseIISIntegration()
24
                 .Build();
24
                 .Build();
25
     }
25
     }

+ 8
- 0
UnivateProperties_API/Repository/Communication/MailRepository.cs View File

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

+ 16
- 14
UnivateProperties_API/Repository/Timeshare/IResortRepository.cs View File

29
             _dbContext = dbContext;
29
             _dbContext = dbContext;
30
         }
30
         }
31
 
31
 
32
-        public string GetResortDescription(string resortCode)
32
+        public string GetResortDescription(string resortId)
33
         {
33
         {
34
             var requestDataURL = MyCommon.Reservations.Replace("ReservationsWebService.asmx", "");
34
             var requestDataURL = MyCommon.Reservations.Replace("ReservationsWebService.asmx", "");
35
             var client = new RestClient(MyCommon.Reservations)
35
             var client = new RestClient(MyCommon.Reservations)
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>"
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
                 , MyCommon.ReservationsUserCode
45
                 , MyCommon.ReservationsUserCode
46
                 , MyCommon.ReservationsPassword
46
                 , MyCommon.ReservationsPassword
47
-                , resortCode
47
+                , resortId
48
                 , requestDataURL)
48
                 , requestDataURL)
49
                 , ParameterType.RequestBody);
49
                 , ParameterType.RequestBody);
50
             IRestResponse response = client.Execute(request);           
50
             IRestResponse response = client.Execute(request);           
107
                 if (!resortNames.Contains(week.ResortName))
107
                 if (!resortNames.Contains(week.ResortName))
108
                 {
108
                 {
109
                     resortNames.Add(week.ResortName);
109
                     resortNames.Add(week.ResortName);
110
+                    resortObject.resortId = int.Parse(TenderWeeksHelper.GetResortId(week.ResortName));
110
                     resortObject.resortName = week.ResortName;
111
                     resortObject.resortName = week.ResortName;
111
                     resortObject.resortCode = week.ResortCode;
112
                     resortObject.resortCode = week.ResortCode;
112
                     resortObject.resortRegion = provinces.Where(p => p.Id == week.RegionId);
113
                     resortObject.resortRegion = provinces.Where(p => p.Id == week.RegionId);
139
             WeekRepository weekRepo = new WeekRepository(_dbContext);
140
             WeekRepository weekRepo = new WeekRepository(_dbContext);
140
             var weeks = weekRepo.GetDtoListAll();
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
                 Timeout = -1
145
                 Timeout = -1
145
             };
146
             };
149
 
150
 
150
             foreach(var resort in UniResorts)
151
             foreach(var resort in UniResorts)
151
             {
152
             {
152
-                if (!string.IsNullOrEmpty(resort.ResortCode))
153
-                {                   
153
+                //if (!string.IsNullOrEmpty(resort.ResortCode))
154
+                //{
154
                     ResortDisplay desp = new ResortDisplay()
155
                     ResortDisplay desp = new ResortDisplay()
155
                     {
156
                     {
157
+                        ResortId = resort.Id.ToString(),
156
                         ResortCode = resort.ResortCode,
158
                         ResortCode = resort.ResortCode,
157
                         ResortName = resort.ResortName
159
                         ResortName = resort.ResortName
158
                     };
160
                     };
159
 
161
 
160
-                    var images = GetResortImages(resort.ResortCode);
162
+                    var images = GetResortImages(desp.ResortId);
161
                     if (images == null || images.Count == 0)
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
                             Timeout = -1
167
                             Timeout = -1
166
                         };
168
                         };
178
                     desp.WeeksAvailable = weeks.Where(w => w.Resort.ResortCode == resort.ResortCode).Where(x => x.Publish == true).Count();
180
                     desp.WeeksAvailable = weeks.Where(w => w.Resort.ResortCode == resort.ResortCode).Where(x => x.Publish == true).Count();
179
 
181
 
180
                     resorts.Add(desp);
182
                     resorts.Add(desp);
181
-                }
183
+                //}
182
             }
184
             }
183
 
185
 
184
             return resorts.OrderBy(r => r.ResortCode).ToList();
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
             #region Get Resort Data
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
                 Timeout = -1
194
                 Timeout = -1
193
             };
195
             };
197
             #endregion
199
             #endregion
198
 
200
 
199
             #region Get Layout
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
                 Timeout = -1
204
                 Timeout = -1
203
             };
205
             };
211
             #endregion
213
             #endregion
212
 
214
 
213
             #region GetImages
215
             #region GetImages
214
-            data.Images = GetResortImages(resortCode);
216
+            data.Images = GetResortImages(resortId);
215
             if (data.Images == null || data.Images.Count == 0)
217
             if (data.Images == null || data.Images.Count == 0)
216
             {
218
             {
217
                 data.Images = new List<string>();
219
                 data.Images = new List<string>();
218
                 int count = 0;
220
                 int count = 0;
219
                 while (count < 5)
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
                         Timeout = -1
225
                         Timeout = -1
224
                     };
226
                     };
232
 #endregion
234
 #endregion
233
 
235
 
234
             #region Get Description
236
             #region Get Description
235
-            data.Description = GetResortDescription(resortCode);            
237
+            data.Description = GetResortDescription(resortId);            
236
             #endregion
238
             #endregion
237
 
239
 
238
             return data; 
240
             return data; 

+ 44
- 32
UnivateProperties_API/Repository/Timeshare/WeekRepository.cs View File

2
 using Abp.Extensions;
2
 using Abp.Extensions;
3
 using Microsoft.CodeAnalysis;
3
 using Microsoft.CodeAnalysis;
4
 using Microsoft.EntityFrameworkCore;
4
 using Microsoft.EntityFrameworkCore;
5
+using Newtonsoft.Json;
5
 using RestSharp;
6
 using RestSharp;
6
 using System;
7
 using System;
7
 using System.Collections.Generic;
8
 using System.Collections.Generic;
75
             return null;
76
             return null;
76
         }
77
         }
77
 
78
 
78
-        public List<WeekDto> GetAllByResortCode(string resortCode) 
79
+        public List<WeekDto> GetAllByResortCode(string resortCode)
79
         {
80
         {
80
             List<WeekDto> list = new List<WeekDto>();
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
                 list.Add(new WeekDto(item));
86
                 list.Add(new WeekDto(item));
84
             }
87
             }
85
 
88
 
86
             var listIds = list.Select(x => x.WeekUni).ToList();
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
             return list;
95
             return list;
94
         }
96
         }
95
 
97
 
103
             }
105
             }
104
             return weeklist;
106
             return weeklist;
105
         }
107
         }
106
-
107
         private List<TimeshareWeek> GetAllUsingResortCode(string resortCode)
108
         private List<TimeshareWeek> GetAllUsingResortCode(string resortCode)
108
         {
109
         {
109
             return _dbContext.Weeks.Where(x => x.ResortCode == resortCode).ToList();
110
             return _dbContext.Weeks.Where(x => x.ResortCode == resortCode).ToList();
259
         {
260
         {
260
             List<RegionDto> list = new List<RegionDto>();
261
             List<RegionDto> list = new List<RegionDto>();
261
             var allItems = GetDtoListAll();
262
             var allItems = GetDtoListAll();
262
-            foreach (var item in allItems)
263
+             foreach (var item in allItems)
263
             {
264
             {
264
                 if (item.Region != null)
265
                 if (item.Region != null)
265
                 {
266
                 {
270
                     foreach (var i in list.Where(x => x.RegionCode == item.Region.RegionCode))
271
                     foreach (var i in list.Where(x => x.RegionCode == item.Region.RegionCode))
271
                     {
272
                     {
272
                         i.TryAddResort(item.Resort.ResortCode, item.Resort.ResortName);
273
                         i.TryAddResort(item.Resort.ResortCode, item.Resort.ResortName);
274
+                        
273
                     }
275
                     }
274
                 }
276
                 }
275
             }
277
             }
280
                 foreach (var resort in region.Resorts)
282
                 foreach (var resort in region.Resorts)
281
                 {
283
                 {
282
                     resort.Available = allItems.Count(x => x.Resort.ResortCode == resort.ResortCode);
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
             return list;
289
             return list;
286
         }
290
         }
287
 
291
 
292
+
293
+
288
         public List<TimeshareWeek> GetDetailedAll()
294
         public List<TimeshareWeek> GetDetailedAll()
289
         {
295
         {
290
             var list = GetAll();
296
             var list = GetAll();
715
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
721
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
716
             {
722
             {
717
                 string result = reader.ReadToEnd();
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
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
758
             using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
750
             {
759
             {
751
                 string result = reader.ReadToEnd();
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
             // Check that all regions are same as other
783
             // Check that all regions are same as other

+ 7
- 10
UnivateProperties_API/Repository/Users/RegisterRepository.cs View File

71
         public Agency CreateAgency(AgencyDto agency)
71
         public Agency CreateAgency(AgencyDto agency)
72
         {
72
         {
73
             // validation
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
             if (!string.IsNullOrEmpty(agency.EaabeffcNumber))
74
             if (!string.IsNullOrEmpty(agency.EaabeffcNumber))
80
             {
75
             {
81
                 var savedAgency = _dbContext.Agencies.Where(x => x.EAABEFFCNumber == agency.EaabeffcNumber).FirstOrDefault();
76
                 var savedAgency = _dbContext.Agencies.Where(x => x.EAABEFFCNumber == agency.EaabeffcNumber).FirstOrDefault();
85
                     {
80
                     {
86
                         AgencyName = agency.Name,
81
                         AgencyName = agency.Name,
87
                         EAABEFFCNumber = agency.EaabeffcNumber,
82
                         EAABEFFCNumber = agency.EaabeffcNumber,
88
-                        CompanyRegNumber = agency.RegNo
83
+                        CompanyRegNumber = agency.CompanyRegNumber
89
                     };
84
                     };
90
                     _dbContext.Agencies.Add(a);
85
                     _dbContext.Agencies.Add(a);
91
                     CreatePerson(agency.User, PersonType.Agent, false, a);
86
                     CreatePerson(agency.User, PersonType.Agent, false, a);
92
-
93
-
87
+                    _dbContext.SaveChanges();
94
                     return a;
88
                     return a;
95
                 }
89
                 }
96
                 else
90
                 else
99
                     _dbContext.SaveChanges();
93
                     _dbContext.SaveChanges();
100
                     return savedAgency;
94
                     return savedAgency;
101
                 }
95
                 }
96
+
102
             }
97
             }
103
             else 
98
             else 
104
             {
99
             {
115
                 throw new AppException("Password is required");
110
                 throw new AppException("Password is required");
116
 
111
 
117
             if (_dbContext.Users.Any(x => x.Username == individual.Username))
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
             MyCommon.CreatePasswordHash(individual.Password, out byte[] passwordHash, out byte[] passwordSalt);
117
             MyCommon.CreatePasswordHash(individual.Password, out byte[] passwordHash, out byte[] passwordSalt);
121
 
118
 
438
             }
435
             }
439
             else
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 View File

9
   },
9
   },
10
   "AllowedHosts": "*",
10
   "AllowedHosts": "*",
11
   "ConnectionStrings": {
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
     //"DefaultConnection": "Data Source=localhost;Initial Catalog=UniVate;Persist Security Info=True;User Id=Provision;Password=J%Xvk8xGeT;Pooling=false;",
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
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",
16
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",
16
     "ReservationsURL": "https://www.pvsl.co.za:85/ReservationsWebService.asmx", //Please note that ReservationsWebService must be in this case. 
17
     "ReservationsURL": "https://www.pvsl.co.za:85/ReservationsWebService.asmx", //Please note that ReservationsWebService must be in this case. 
17
     "ReservationsUserCode": "UniInt",
18
     "ReservationsUserCode": "UniInt",

Loading…
Cancel
Save