Browse Source

Checkin timeshare

master
Kobus 5 years ago
parent
commit
998226d891
24 changed files with 3014 additions and 51 deletions
  1. 7
    0
      UnivateProperties_API/Containers/IDisplay.cs
  2. 39
    0
      UnivateProperties_API/Containers/Timeshare/Detailed/DetailedAddress.cs
  3. 33
    0
      UnivateProperties_API/Containers/Timeshare/Detailed/DetailedBankDetails.cs
  4. 47
    0
      UnivateProperties_API/Containers/Timeshare/Detailed/DetailedOwner.cs
  5. 78
    0
      UnivateProperties_API/Containers/Timeshare/Detailed/DetailedWeekDto.cs
  6. 3
    1
      UnivateProperties_API/Containers/Timeshare/RegionDto.cs
  7. 3
    1
      UnivateProperties_API/Containers/Timeshare/ResortDto.cs
  8. 3
    5
      UnivateProperties_API/Containers/Timeshare/StatusDto.cs
  9. 20
    11
      UnivateProperties_API/Containers/Timeshare/WeekDto.cs
  10. 2
    0
      UnivateProperties_API/Context/DataContext.cs
  11. 1
    4
      UnivateProperties_API/Controllers/Timeshare/TimeshareWeekController.cs
  12. 1233
    0
      UnivateProperties_API/Migrations/20191021143440_MappingBank.Designer.cs
  13. 128
    0
      UnivateProperties_API/Migrations/20191021143440_MappingBank.cs
  14. 1239
    0
      UnivateProperties_API/Migrations/20191022055635_AddedWeekProps.Designer.cs
  15. 41
    0
      UnivateProperties_API/Migrations/20191022055635_AddedWeekProps.cs
  16. 31
    3
      UnivateProperties_API/Migrations/DataContextModelSnapshot.cs
  17. 5
    2
      UnivateProperties_API/Model/Banks/BankAccount.cs
  18. 3
    1
      UnivateProperties_API/Model/BaseEntity.cs
  19. 6
    4
      UnivateProperties_API/Model/Misc/Address.cs
  20. 5
    1
      UnivateProperties_API/Model/ProcessFlow/ProcessFlow.cs
  21. 1
    0
      UnivateProperties_API/Model/Timeshare/Status.cs
  22. 21
    0
      UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs
  23. 6
    1
      UnivateProperties_API/Model/Users/Individual.cs
  24. 59
    17
      UnivateProperties_API/Repository/Timeshare/WeekRepository.cs

+ 7
- 0
UnivateProperties_API/Containers/IDisplay.cs View File

1
+namespace UnivateProperties_API.Containers
2
+{
3
+    public interface IDisplay
4
+    {
5
+        string Display { get; }
6
+    }
7
+}

+ 39
- 0
UnivateProperties_API/Containers/Timeshare/Detailed/DetailedAddress.cs View File

1
+using UnivateProperties_API.Model.Misc;
2
+
3
+namespace UnivateProperties_API.Containers.Timeshare.Detailed
4
+{
5
+    public class DetailedAddress
6
+    {
7
+        public DetailedAddress()
8
+        {
9
+
10
+        }
11
+
12
+        public DetailedAddress(int id, string streetNumber, string street, string suburb, string city, string postalCode)
13
+        {
14
+            Id = id;
15
+            StreetNumber = streetNumber;
16
+            Street = street;
17
+            Suburb = suburb;
18
+            City = city;
19
+            PostalCode = postalCode;
20
+        }
21
+
22
+        public DetailedAddress(Address address)
23
+        {
24
+            Id = address.Id;
25
+            StreetNumber = address.StreetNumber;
26
+            Street = address.Street;
27
+            Suburb = address.Suburb;
28
+            City = address.City;
29
+            PostalCode = address.PostalCode;
30
+        }
31
+
32
+        public int Id { get; set; }
33
+        public string StreetNumber { get; set; }
34
+        public string Street { get; set; }
35
+        public string Suburb { get; set; }
36
+        public string City { get; set; }
37
+        public string PostalCode { get; set; }
38
+    }
39
+}

+ 33
- 0
UnivateProperties_API/Containers/Timeshare/Detailed/DetailedBankDetails.cs View File

1
+using UnivateProperties_API.Model.Banks;
2
+
3
+namespace UnivateProperties_API.Containers.Timeshare.Detailed
4
+{
5
+    public class DetailedBankDetails
6
+    {
7
+        public DetailedBankDetails()
8
+        {
9
+
10
+        }
11
+
12
+        public DetailedBankDetails(int id, int bankId, string accountNumber, string accountHolder)
13
+        {
14
+            Id = id;
15
+            BankId = bankId;
16
+            AccountHolder = accountHolder;
17
+            AccountNumber = accountNumber;
18
+        }
19
+
20
+        public DetailedBankDetails(BankAccount bankAccount)
21
+        {
22
+            Id = bankAccount.Id;
23
+            BankId = bankAccount.BankId;
24
+            AccountHolder = bankAccount.AccountHolder;
25
+            AccountNumber = bankAccount.AccountNumber;
26
+        }
27
+
28
+        public int Id { get; set; }
29
+        public int? BankId { get; set; }
30
+        public string AccountHolder { get; set; }
31
+        public string AccountNumber { get; set; }
32
+    }
33
+}

+ 47
- 0
UnivateProperties_API/Containers/Timeshare/Detailed/DetailedOwner.cs View File

1
+using UnivateProperties_API.Model.Users;
2
+
3
+namespace UnivateProperties_API.Containers.Timeshare.Detailed
4
+{
5
+    public class DetailedOwner
6
+    {
7
+        public DetailedOwner()
8
+        {
9
+
10
+        }
11
+
12
+        public DetailedOwner(Individual individual)
13
+        {
14
+            Id = individual.Id;
15
+            Name = individual.Name;
16
+            Surname = individual.Surname;
17
+            IdNumber = individual.IdNumber;
18
+            CompanyRegNumber = individual.CompanyRegNumber;
19
+            MaritalStatus = individual.MaritalStatus;
20
+            EmailAddress = individual.Email;
21
+            CellNumber = individual.CellNumber;
22
+            LandlineNumber = individual.Telephone;
23
+            if (individual.Address != null)
24
+            {
25
+                Address = new DetailedAddress(individual.Address);
26
+            }
27
+            else Address = new DetailedAddress();
28
+            if (BankingDetails != null)
29
+            {
30
+                BankingDetails = new DetailedBankDetails(individual.BankAccount);
31
+            }
32
+            else BankingDetails = new DetailedBankDetails();
33
+        }
34
+
35
+        public int Id { get; set; }
36
+        public string Name { get; set; }
37
+        public string Surname { get; set; }
38
+        public string IdNumber { get; set; }
39
+        public string CompanyRegNumber { get; set; }
40
+        public string MaritalStatus { get; set; }
41
+        public string EmailAddress { get; set; }
42
+        public string CellNumber { get; set; }
43
+        public string LandlineNumber { get; set; }
44
+        public DetailedAddress Address { get; set; }
45
+        public DetailedBankDetails BankingDetails { get; set; }
46
+    }
47
+}

+ 78
- 0
UnivateProperties_API/Containers/Timeshare/Detailed/DetailedWeekDto.cs View File

1
+using System;
2
+using UnivateProperties_API.Model.Timeshare;
3
+
4
+namespace UnivateProperties_API.Containers.Timeshare.Detailed
5
+{
6
+    public class DetailedWeekDto
7
+    {
8
+        public DetailedWeekDto()
9
+        {
10
+
11
+        }
12
+
13
+        public DetailedWeekDto(TimeshareWeek week)
14
+        {
15
+            Id = week.Id;
16
+            ReferedByAgent = week.ReferedByAgent;
17
+            AgentId = week.AgentId;
18
+            AgencyId = week.AgencyId;
19
+            OtherResort = week.OtherResort;
20
+            OtherResortName = week.OtherResortName;
21
+            Resort = new ResortDto(week.ResortCode, week.ResortName);
22
+            ResortCode = week.ResortCode;
23
+            ResortName = week.ResortName;
24
+            RegionId = week.RegionId;
25
+            Season = week.Season;
26
+            Module = week.Module;
27
+            UnitNumber = week.UnitNumber;
28
+            Bedrooms = week.Bedrooms;
29
+            MaxSleep = week.MaxSleep;
30
+            WeekNumber = week.WeekNumber;
31
+            LevyAmount = week.LevyAmount;
32
+            CurrentYearBanked = week.CurrentYearBanked;
33
+            BankedWith = week.BankedWith;
34
+            LeviesPaidInFull = week.LeviesPaidInFull;
35
+            WeekPlacedForRental = week.WeekPlacedForRental;
36
+            OriginalPurchaseDate = week.OriginalPurchaseDate.ToShortDateString().Replace('/', '-');
37
+            OriginalPurchasePrice = week.OriginalPurchasePrice;
38
+            ArrivalDate = week.ArrivalDate.ToShortDateString().Replace('/', '-');
39
+            DepartureDate = week.DepartureDate.ToShortDateString().Replace('/', '-');
40
+            SellPrice = week.SellPrice;
41
+            AgentCommission = week.AgentCommision;
42
+            Mandate = week.Mandate;
43
+            Status = week.Status.Display;
44
+            Owner = new DetailedOwner(week.Owner);
45
+        }
46
+
47
+        public int Id { get; set; }
48
+        public bool ReferedByAgent { get; set; }
49
+        public int? AgentId { get; set; }
50
+        public int? AgencyId { get; set; }
51
+        public bool OtherResort { get; set; }
52
+        public string OtherResortName { get; set; }
53
+        public ResortDto Resort { get; set; }
54
+        public string ResortCode { get; set; }
55
+        public string ResortName { get; set; }
56
+        public int RegionId { get; set; }
57
+        public string Season { get; set; }
58
+        public string Module { get; set; }
59
+        public string UnitNumber { get; set; }
60
+        public int Bedrooms { get; set; }
61
+        public int MaxSleep { get; set; }
62
+        public string WeekNumber { get; set; }
63
+        public double LevyAmount { get; set; }
64
+        public bool CurrentYearBanked { get; set; }
65
+        public string BankedWith { get; set; }
66
+        public bool LeviesPaidInFull { get; set; }
67
+        public bool WeekPlacedForRental { get; set; }
68
+        public double OriginalPurchasePrice { get; set; }
69
+        public string OriginalPurchaseDate { get; set; }
70
+        public string ArrivalDate { get; set; }
71
+        public string DepartureDate { get; set; }
72
+        public double SellPrice { get; set; }
73
+        public double AgentCommission { get; set; }
74
+        public string Mandate { get; set; }
75
+        public string Status { get; set; }
76
+        public DetailedOwner Owner { get; set; }
77
+    }
78
+}

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

3
 
3
 
4
 namespace UnivateProperties_API.Containers.Timeshare
4
 namespace UnivateProperties_API.Containers.Timeshare
5
 {
5
 {
6
-    public class RegionDto
6
+    public class RegionDto : IDisplay
7
     {
7
     {
8
         public RegionDto()
8
         public RegionDto()
9
         {
9
         {
37
             }
37
             }
38
         }
38
         }
39
 
39
 
40
+        public string Display => RegionName;
41
+
40
         public void TryAddResort(string resortCode, string resortName)
42
         public void TryAddResort(string resortCode, string resortName)
41
         {
43
         {
42
             if (!Resorts.Any(x => x.ResortCode == resortCode))
44
             if (!Resorts.Any(x => x.ResortCode == resortCode))

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

1
 namespace UnivateProperties_API.Containers.Timeshare
1
 namespace UnivateProperties_API.Containers.Timeshare
2
 {
2
 {
3
-    public class ResortDto
3
+    public class ResortDto : IDisplay
4
     {
4
     {
5
         public ResortDto()
5
         public ResortDto()
6
         {
6
         {
16
         public string ResortCode { get; set; }
16
         public string ResortCode { get; set; }
17
         public string ResortName { get; set; }
17
         public string ResortName { get; set; }
18
         public int Available { get; set; }
18
         public int Available { get; set; }
19
+
20
+        public string Display => ResortName;
19
     }
21
     }
20
 }
22
 }

+ 3
- 5
UnivateProperties_API/Containers/Timeshare/StatusDto.cs View File

1
 namespace UnivateProperties_API.Containers.Timeshare
1
 namespace UnivateProperties_API.Containers.Timeshare
2
 {
2
 {
3
-    public class StatusDto
3
+    public class StatusDto : IDisplay
4
     {
4
     {
5
         public StatusDto()
5
         public StatusDto()
6
         {
6
         {
17
         public int Id { get; set; }
17
         public int Id { get; set; }
18
         public string Code { get; set; }
18
         public string Code { get; set; }
19
         public string Description { get; set; }
19
         public string Description { get; set; }
20
-        public override string ToString()
21
-        {
22
-            return $"{Code} - {Description}";
23
-        }
20
+
21
+        public string Display => $"{Code} - {Description}";
24
     }
22
     }
25
 }
23
 }

+ 20
- 11
UnivateProperties_API/Containers/Timeshare/WeekDto.cs View File

6
 
6
 
7
 namespace UnivateProperties_API.Containers.Timeshare
7
 namespace UnivateProperties_API.Containers.Timeshare
8
 {
8
 {
9
-    public class WeekDto
9
+    public class WeekDto : IDisplay
10
     {
10
     {
11
         public WeekDto()
11
         public WeekDto()
12
         {
12
         {
13
 
13
 
14
         }
14
         }
15
 
15
 
16
-        public WeekDto(string line)
16
+        public WeekDto(int id,string line)
17
         {
17
         {
18
+            Id = id;
18
             List<string> split = line.Split(",").ToList();
19
             List<string> split = line.Split(",").ToList();
19
             AgentAsRep = false;
20
             AgentAsRep = false;
20
             Resort = new ResortDto(split[0].Trim(), split[0].Trim());
21
             Resort = new ResortDto(split[0].Trim(), split[0].Trim());
40
             {
41
             {
41
                 DepartureDate = tempDate;
42
                 DepartureDate = tempDate;
42
             }
43
             }
43
-            Region = new RegionDto() { RegionCode = split[24] };
44
+            Region = new RegionDto() { RegionCode = split[24].Trim() };
45
+            IsTender = true;
46
+            ReferedByAgent = false;
44
         }
47
         }
45
 
48
 
46
         public WeekDto(TimeshareWeek week)
49
         public WeekDto(TimeshareWeek week)
52
             Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
55
             Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
53
             Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
56
             Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
54
             Resort = new ResortDto(week.ResortCode, week.ResortName);
57
             Resort = new ResortDto(week.ResortCode, week.ResortName);
55
-            Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Description, week.Region?.Code);
58
+            Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
56
             Status = new StatusDto(week.Status.Id, week.Status?.Code, week.Status?.Description);
59
             Status = new StatusDto(week.Status.Id, week.Status?.Code, week.Status?.Description);
57
             Bedrooms = week.Bedrooms;
60
             Bedrooms = week.Bedrooms;
58
             MaxSleep = week.MaxSleep;
61
             MaxSleep = week.MaxSleep;
63
             ArrivalDate = week.ArrivalDate;
66
             ArrivalDate = week.ArrivalDate;
64
             DepartureDate = week.DepartureDate;
67
             DepartureDate = week.DepartureDate;
65
             SellPrice = week.SellPrice;
68
             SellPrice = week.SellPrice;
69
+            IsTender = false;
70
+            ReferedByAgent = week.ReferedByAgent;
66
         }
71
         }
67
 
72
 
68
         public int Id { get; set; }
73
         public int Id { get; set; }
69
-        public bool AgentAsRep { get; set; }
70
-        public bool OtherResort { get; set; }
71
-        public string Agency { get; set; }
72
-        public string Agent { get; set; }
73
-        public string Owner { get; set; }
74
         public ResortDto Resort { get; set; }
74
         public ResortDto Resort { get; set; }
75
         public RegionDto Region { get; set; }
75
         public RegionDto Region { get; set; }
76
         public StatusDto Status { get; set; }
76
         public StatusDto Status { get; set; }
77
-        public int Bedrooms { get; set; }
78
-        public int MaxSleep { get; set; }
79
         public string UnitNumber { get; set; }
77
         public string UnitNumber { get; set; }
80
         public string WeekNumber { get; set; }
78
         public string WeekNumber { get; set; }
79
+        public string Agency { get; set; }
80
+        public string Agent { get; set; }
81
+        public string Owner { get; set; }
82
+        public bool AgentAsRep { get; set; }
83
+        public bool OtherResort { get; set; }
84
+        public int Bedrooms { get; set; }
85
+        public int MaxSleep { get; set; }
81
         public double LevyAmount { get; set; }
86
         public double LevyAmount { get; set; }
82
         public bool CurrentYearBanked { get; set; }
87
         public bool CurrentYearBanked { get; set; }
83
         public string BankedWith { get; set; }
88
         public string BankedWith { get; set; }
84
         public DateTime ArrivalDate { get; set; }
89
         public DateTime ArrivalDate { get; set; }
85
         public DateTime DepartureDate { get; set; }
90
         public DateTime DepartureDate { get; set; }
86
         public double SellPrice { get; set; }
91
         public double SellPrice { get; set; }
92
+        public bool IsTender { get; set; }
93
+        public bool ReferedByAgent { get; set; }
94
+
95
+        public string Display => $"{Resort.Display}  ({ArrivalDate.ToShortDateString()} - {DepartureDate.ToShortDateString()})";
87
     }
96
     }
88
 }
97
 }

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

169
             modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
169
             modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
170
             modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
170
             modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
171
             modelBuilder.Entity<Template>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
171
             modelBuilder.Entity<Template>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
172
+
173
+            
172
         }
174
         }
173
     }
175
     }
174
 }
176
 }

+ 1
- 4
UnivateProperties_API/Controllers/Timeshare/TimeshareWeekController.cs View File

1
 using Microsoft.AspNetCore.Mvc;
1
 using Microsoft.AspNetCore.Mvc;
2
-using System;
3
-using System.Collections.Generic;
4
-using System.Linq;
5
 using System.Transactions;
2
 using System.Transactions;
6
 using UnivateProperties_API.Containers.Timeshare;
3
 using UnivateProperties_API.Containers.Timeshare;
7
 using UnivateProperties_API.Model.Timeshare;
4
 using UnivateProperties_API.Model.Timeshare;
31
         [HttpGet("{id}")]
28
         [HttpGet("{id}")]
32
         public IActionResult Get(int id)
29
         public IActionResult Get(int id)
33
         {
30
         {
34
-            var item = _Repo.Get(x => x.Id == id);
31
+            var item = (_Repo as WeekRepository).GetMyDetailed(x => x.Id == id);
35
             return new OkObjectResult(item);
32
             return new OkObjectResult(item);
36
         }
33
         }
37
 
34
 

+ 1233
- 0
UnivateProperties_API/Migrations/20191021143440_MappingBank.Designer.cs
File diff suppressed because it is too large
View File


+ 128
- 0
UnivateProperties_API/Migrations/20191021143440_MappingBank.cs View File

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class MappingBank : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.DropForeignKey(
10
+                name: "FK_BankAccounts_Banks_BankId",
11
+                table: "BankAccounts");
12
+
13
+            migrationBuilder.AddColumn<string>(
14
+                name: "Video",
15
+                table: "Properties",
16
+                nullable: true);
17
+
18
+            migrationBuilder.AddColumn<string>(
19
+                name: "VirtualTour",
20
+                table: "Properties",
21
+                nullable: true);
22
+
23
+            migrationBuilder.AddColumn<int>(
24
+                name: "BankAccountId",
25
+                table: "Individuals",
26
+                nullable: true);
27
+
28
+            migrationBuilder.AlterColumn<int>(
29
+                name: "BankId",
30
+                table: "BankAccounts",
31
+                nullable: true,
32
+                oldClrType: typeof(int));
33
+
34
+            migrationBuilder.AddColumn<int>(
35
+                name: "OwnerId",
36
+                table: "Addresses",
37
+                nullable: true);
38
+
39
+            migrationBuilder.CreateIndex(
40
+                name: "IX_Individuals_BankAccountId",
41
+                table: "Individuals",
42
+                column: "BankAccountId");
43
+
44
+            migrationBuilder.CreateIndex(
45
+                name: "IX_Addresses_OwnerId",
46
+                table: "Addresses",
47
+                column: "OwnerId");
48
+
49
+            migrationBuilder.AddForeignKey(
50
+                name: "FK_Addresses_Individuals_OwnerId",
51
+                table: "Addresses",
52
+                column: "OwnerId",
53
+                principalTable: "Individuals",
54
+                principalColumn: "Id",
55
+                onDelete: ReferentialAction.Restrict);
56
+
57
+            migrationBuilder.AddForeignKey(
58
+                name: "FK_BankAccounts_Banks_BankId",
59
+                table: "BankAccounts",
60
+                column: "BankId",
61
+                principalTable: "Banks",
62
+                principalColumn: "Id",
63
+                onDelete: ReferentialAction.Restrict);
64
+
65
+            migrationBuilder.AddForeignKey(
66
+                name: "FK_Individuals_BankAccounts_BankAccountId",
67
+                table: "Individuals",
68
+                column: "BankAccountId",
69
+                principalTable: "BankAccounts",
70
+                principalColumn: "Id",
71
+                onDelete: ReferentialAction.Restrict);
72
+        }
73
+
74
+        protected override void Down(MigrationBuilder migrationBuilder)
75
+        {
76
+            migrationBuilder.DropForeignKey(
77
+                name: "FK_Addresses_Individuals_OwnerId",
78
+                table: "Addresses");
79
+
80
+            migrationBuilder.DropForeignKey(
81
+                name: "FK_BankAccounts_Banks_BankId",
82
+                table: "BankAccounts");
83
+
84
+            migrationBuilder.DropForeignKey(
85
+                name: "FK_Individuals_BankAccounts_BankAccountId",
86
+                table: "Individuals");
87
+
88
+            migrationBuilder.DropIndex(
89
+                name: "IX_Individuals_BankAccountId",
90
+                table: "Individuals");
91
+
92
+            migrationBuilder.DropIndex(
93
+                name: "IX_Addresses_OwnerId",
94
+                table: "Addresses");
95
+
96
+            migrationBuilder.DropColumn(
97
+                name: "Video",
98
+                table: "Properties");
99
+
100
+            migrationBuilder.DropColumn(
101
+                name: "VirtualTour",
102
+                table: "Properties");
103
+
104
+            migrationBuilder.DropColumn(
105
+                name: "BankAccountId",
106
+                table: "Individuals");
107
+
108
+            migrationBuilder.DropColumn(
109
+                name: "OwnerId",
110
+                table: "Addresses");
111
+
112
+            migrationBuilder.AlterColumn<int>(
113
+                name: "BankId",
114
+                table: "BankAccounts",
115
+                nullable: false,
116
+                oldClrType: typeof(int),
117
+                oldNullable: true);
118
+
119
+            migrationBuilder.AddForeignKey(
120
+                name: "FK_BankAccounts_Banks_BankId",
121
+                table: "BankAccounts",
122
+                column: "BankId",
123
+                principalTable: "Banks",
124
+                principalColumn: "Id",
125
+                onDelete: ReferentialAction.Cascade);
126
+        }
127
+    }
128
+}

+ 1239
- 0
UnivateProperties_API/Migrations/20191022055635_AddedWeekProps.Designer.cs
File diff suppressed because it is too large
View File


+ 41
- 0
UnivateProperties_API/Migrations/20191022055635_AddedWeekProps.cs View File

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class AddedWeekProps : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<double>(
10
+                name: "AgentCommision",
11
+                table: "Weeks",
12
+                nullable: false,
13
+                defaultValue: 0.0);
14
+
15
+            migrationBuilder.AddColumn<string>(
16
+                name: "Mandate",
17
+                table: "Weeks",
18
+                nullable: true);
19
+
20
+            migrationBuilder.AddColumn<string>(
21
+                name: "OtherResortName",
22
+                table: "Weeks",
23
+                nullable: true);
24
+        }
25
+
26
+        protected override void Down(MigrationBuilder migrationBuilder)
27
+        {
28
+            migrationBuilder.DropColumn(
29
+                name: "AgentCommision",
30
+                table: "Weeks");
31
+
32
+            migrationBuilder.DropColumn(
33
+                name: "Mandate",
34
+                table: "Weeks");
35
+
36
+            migrationBuilder.DropColumn(
37
+                name: "OtherResortName",
38
+                table: "Weeks");
39
+        }
40
+    }
41
+}

+ 31
- 3
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs View File

50
 
50
 
51
                     b.Property<string>("AccountNumber");
51
                     b.Property<string>("AccountNumber");
52
 
52
 
53
-                    b.Property<int>("BankId");
53
+                    b.Property<int?>("BankId");
54
 
54
 
55
                     b.Property<DateTime>("Created");
55
                     b.Property<DateTime>("Created");
56
 
56
 
254
 
254
 
255
                     b.Property<string>("ModifiedBy");
255
                     b.Property<string>("ModifiedBy");
256
 
256
 
257
+                    b.Property<int?>("OwnerId");
258
+
257
                     b.Property<string>("PostalCode");
259
                     b.Property<string>("PostalCode");
258
 
260
 
259
                     b.Property<string>("Street");
261
                     b.Property<string>("Street");
264
 
266
 
265
                     b.HasKey("Id");
267
                     b.HasKey("Id");
266
 
268
 
269
+                    b.HasIndex("OwnerId");
270
+
267
                     b.ToTable("Addresses");
271
                     b.ToTable("Addresses");
268
                 });
272
                 });
269
 
273
 
412
 
416
 
413
                     b.Property<string>("Unit");
417
                     b.Property<string>("Unit");
414
 
418
 
419
+                    b.Property<string>("Video");
420
+
421
+                    b.Property<string>("VirtualTour");
422
+
415
                     b.HasKey("Id");
423
                     b.HasKey("Id");
416
 
424
 
417
                     b.HasIndex("AgencyId");
425
                     b.HasIndex("AgencyId");
690
 
698
 
691
                     b.Property<bool>("AgentAsRep");
699
                     b.Property<bool>("AgentAsRep");
692
 
700
 
701
+                    b.Property<double>("AgentCommision");
702
+
693
                     b.Property<int?>("AgentId");
703
                     b.Property<int?>("AgentId");
694
 
704
 
695
                     b.Property<DateTime>("ArrivalDate");
705
                     b.Property<DateTime>("ArrivalDate");
710
 
720
 
711
                     b.Property<double>("LevyAmount");
721
                     b.Property<double>("LevyAmount");
712
 
722
 
723
+                    b.Property<string>("Mandate");
724
+
713
                     b.Property<int>("MaxSleep");
725
                     b.Property<int>("MaxSleep");
714
 
726
 
715
                     b.Property<DateTime>("Modified");
727
                     b.Property<DateTime>("Modified");
724
 
736
 
725
                     b.Property<bool>("OtherResort");
737
                     b.Property<bool>("OtherResort");
726
 
738
 
739
+                    b.Property<string>("OtherResortName");
740
+
727
                     b.Property<int>("OwnerId");
741
                     b.Property<int>("OwnerId");
728
 
742
 
729
                     b.Property<bool>("ReferedByAgent");
743
                     b.Property<bool>("ReferedByAgent");
881
 
895
 
882
                     b.Property<int?>("AddressId");
896
                     b.Property<int?>("AddressId");
883
 
897
 
898
+                    b.Property<int?>("BankAccountId");
899
+
884
                     b.Property<string>("CellNumber");
900
                     b.Property<string>("CellNumber");
885
 
901
 
886
                     b.Property<string>("CompanyRegNumber");
902
                     b.Property<string>("CompanyRegNumber");
913
 
929
 
914
                     b.HasIndex("AddressId");
930
                     b.HasIndex("AddressId");
915
 
931
 
932
+                    b.HasIndex("BankAccountId");
933
+
916
                     b.HasIndex("UserId");
934
                     b.HasIndex("UserId");
917
 
935
 
918
                     b.HasIndex("Telephone", "CellNumber", "Email")
936
                     b.HasIndex("Telephone", "CellNumber", "Email")
990
                 {
1008
                 {
991
                     b.HasOne("UnivateProperties_API.Model.Banks.Bank", "Bank")
1009
                     b.HasOne("UnivateProperties_API.Model.Banks.Bank", "Bank")
992
                         .WithMany()
1010
                         .WithMany()
993
-                        .HasForeignKey("BankId")
994
-                        .OnDelete(DeleteBehavior.Cascade);
1011
+                        .HasForeignKey("BankId");
995
 
1012
 
996
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "Owner")
1013
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "Owner")
997
                         .WithMany()
1014
                         .WithMany()
1022
                         .OnDelete(DeleteBehavior.Cascade);
1039
                         .OnDelete(DeleteBehavior.Cascade);
1023
                 });
1040
                 });
1024
 
1041
 
1042
+            modelBuilder.Entity("UnivateProperties_API.Model.Misc.Address", b =>
1043
+                {
1044
+                    b.HasOne("UnivateProperties_API.Model.Users.Individual", "Owner")
1045
+                        .WithMany()
1046
+                        .HasForeignKey("OwnerId");
1047
+                });
1048
+
1025
             modelBuilder.Entity("UnivateProperties_API.Model.ProcessFlow.BidItem", b =>
1049
             modelBuilder.Entity("UnivateProperties_API.Model.ProcessFlow.BidItem", b =>
1026
                 {
1050
                 {
1027
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "BidMaker")
1051
                     b.HasOne("UnivateProperties_API.Model.Users.Individual", "BidMaker")
1192
                         .WithMany()
1216
                         .WithMany()
1193
                         .HasForeignKey("AddressId");
1217
                         .HasForeignKey("AddressId");
1194
 
1218
 
1219
+                    b.HasOne("UnivateProperties_API.Model.Banks.BankAccount", "BankAccount")
1220
+                        .WithMany()
1221
+                        .HasForeignKey("BankAccountId");
1222
+
1195
                     b.HasOne("UnivateProperties_API.Model.Users.User", "User")
1223
                     b.HasOne("UnivateProperties_API.Model.Users.User", "User")
1196
                         .WithMany()
1224
                         .WithMany()
1197
                         .HasForeignKey("UserId");
1225
                         .HasForeignKey("UserId");

+ 5
- 2
UnivateProperties_API/Model/Banks/BankAccount.cs View File

1
-using UnivateProperties_API.Model.Users;
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+using UnivateProperties_API.Model.Users;
2
 
3
 
3
 namespace UnivateProperties_API.Model.Banks
4
 namespace UnivateProperties_API.Model.Banks
4
 {
5
 {
7
         #region Properties
8
         #region Properties
8
         public string AccountHolder { get; set; }
9
         public string AccountHolder { get; set; }
9
         public string AccountNumber { get; set; }
10
         public string AccountNumber { get; set; }
10
-        public int BankId { get; set; }
11
+        [ForeignKey("Bank")]
12
+        public int? BankId { get; set; }
13
+        [ForeignKey("Owner")]
11
         public int? OwnerId { get; set; }
14
         public int? OwnerId { get; set; }
12
         #endregion Properties
15
         #endregion Properties
13
 
16
 

+ 3
- 1
UnivateProperties_API/Model/BaseEntity.cs View File

7
 
7
 
8
 namespace UnivateProperties_API.Model
8
 namespace UnivateProperties_API.Model
9
 {
9
 {
10
-    public class BaseEntity
10
+    public class BaseEntity : IDisplay
11
     {
11
     {
12
         #region Properties
12
         #region Properties
13
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
13
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
19
         [NotMapped]
19
         [NotMapped]
20
         public ValidateEntity Valid { get; set; }
20
         public ValidateEntity Valid { get; set; }
21
         public bool IsDeleted { get; set; } = false;
21
         public bool IsDeleted { get; set; } = false;
22
+        [NotMapped]
23
+        public virtual string Display { get { return ToString(); } }
22
         #endregion
24
         #endregion
23
 
25
 
24
         #region Methods
26
         #region Methods

+ 6
- 4
UnivateProperties_API/Model/Misc/Address.cs View File

1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+using UnivateProperties_API.Model.Users;
5
 
3
 
6
 namespace UnivateProperties_API.Model.Misc
4
 namespace UnivateProperties_API.Model.Misc
7
 {
5
 {
12
         public string Suburb { get; set; }
10
         public string Suburb { get; set; }
13
         public string City { get; set; }
11
         public string City { get; set; }
14
         public string PostalCode { get; set; }
12
         public string PostalCode { get; set; }
13
+        [ForeignKey("Owner")]
14
+        public int? OwnerId { get; set; }
15
+
16
+        public virtual Individual Owner { get; set; }
15
     }
17
     }
16
 }
18
 }

+ 5
- 1
UnivateProperties_API/Model/ProcessFlow/ProcessFlow.cs View File

1
-using UnivateProperties_API.Model.Timeshare;
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+using UnivateProperties_API.Model.Timeshare;
2
 
3
 
3
 namespace UnivateProperties_API.Model.ProcessFlow
4
 namespace UnivateProperties_API.Model.ProcessFlow
4
 {
5
 {
5
     public class ProcessFlow : BaseEntity
6
     public class ProcessFlow : BaseEntity
6
     {
7
     {
8
+        [ForeignKey("Timeshare")]
7
         public int? TimeshareID { get; set; }
9
         public int? TimeshareID { get; set; }
10
+        [ForeignKey("Property")]
8
         public int? PropertyID { get; set; }
11
         public int? PropertyID { get; set; }
12
+        [ForeignKey("Status")]
9
         public int StatusID { get; set; }
13
         public int StatusID { get; set; }
10
 
14
 
11
 
15
 

+ 1
- 0
UnivateProperties_API/Model/Timeshare/Status.cs View File

5
         public string Code { get; set; }
5
         public string Code { get; set; }
6
         public string Description { get; set; }
6
         public string Description { get; set; }
7
         public StatusType StatusType { get; set; }
7
         public StatusType StatusType { get; set; }
8
+        public override string Display => $"{Description} ({Code})";
8
     }
9
     }
9
 }
10
 }

+ 21
- 0
UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs View File

1
 using System;
1
 using System;
2
 using System.Collections.Generic;
2
 using System.Collections.Generic;
3
 using System.ComponentModel.DataAnnotations.Schema;
3
 using System.ComponentModel.DataAnnotations.Schema;
4
+using UnivateProperties_API.Containers.Timeshare;
4
 using UnivateProperties_API.Model.ProcessFlow;
5
 using UnivateProperties_API.Model.ProcessFlow;
5
 using UnivateProperties_API.Model.Region;
6
 using UnivateProperties_API.Model.Region;
6
 using UnivateProperties_API.Model.Users;
7
 using UnivateProperties_API.Model.Users;
9
 {
10
 {
10
     public class TimeshareWeek : BaseEntity
11
     public class TimeshareWeek : BaseEntity
11
     {
12
     {
13
+        TimeshareWeek()
14
+        {
15
+
16
+        }
17
+
18
+        TimeshareWeek(WeekDto week)
19
+        {
20
+            ReferedByAgent = week.ReferedByAgent;
21
+            AgentAsRep = false;
22
+            ResortCode = week.Resort.ResortCode;
23
+            ResortName = week.Resort.ResortName;
24
+            RegionId = week.Region.Id;
25
+            Bedrooms = week.Bedrooms;
26
+            MaxSleep = week.MaxSleep;
27
+            UnitNumber = week.UnitNumber;
28
+        }
29
+
12
         #region Properties
30
         #region Properties
13
         public bool ReferedByAgent { get; set; }
31
         public bool ReferedByAgent { get; set; }
14
         [ForeignKey("Agent")]
32
         [ForeignKey("Agent")]
20
 
38
 
21
         public bool AgentAsRep { get; set; }
39
         public bool AgentAsRep { get; set; }
22
         public bool OtherResort { get; set; }
40
         public bool OtherResort { get; set; }
41
+        public string OtherResortName { get; set; }
23
         public string ResortCode { get; set; }
42
         public string ResortCode { get; set; }
24
         public string ResortName { get; set; }
43
         public string ResortName { get; set; }
25
         [ForeignKey("Region")]
44
         [ForeignKey("Region")]
43
         public DateTime DepartureDate { get; set; }
62
         public DateTime DepartureDate { get; set; }
44
         
63
         
45
         public double SellPrice { get; set; }
64
         public double SellPrice { get; set; }
65
+        public double AgentCommision { get; set; }
66
+        public string Mandate { get; set; }
46
 
67
 
47
         [ForeignKey("Status")]
68
         [ForeignKey("Status")]
48
         public int StatusId { get; set; }
69
         public int StatusId { get; set; }

+ 6
- 1
UnivateProperties_API/Model/Users/Individual.cs View File

1
 using System.Collections.Generic;
1
 using System.Collections.Generic;
2
 using System.ComponentModel.DataAnnotations;
2
 using System.ComponentModel.DataAnnotations;
3
 using System.ComponentModel.DataAnnotations.Schema;
3
 using System.ComponentModel.DataAnnotations.Schema;
4
+using UnivateProperties_API.Model.Banks;
4
 using UnivateProperties_API.Model.Misc;
5
 using UnivateProperties_API.Model.Misc;
5
 using UnivateProperties_API.Model.Properties;
6
 using UnivateProperties_API.Model.Properties;
6
 
7
 
19
         public string IdNumber { get; set; }
20
         public string IdNumber { get; set; }
20
         public string CompanyRegNumber { get; set; }
21
         public string CompanyRegNumber { get; set; }
21
         public string MaritalStatus { get; set; }
22
         public string MaritalStatus { get; set; }
23
+        [ForeignKey("Address")]
22
         public int? AddressId { get; set; }
24
         public int? AddressId { get; set; }
23
         public string IncomeTaxNumber { get; set; }
25
         public string IncomeTaxNumber { get; set; }
24
-        public virtual Address Address { get; set; }
26
+        [ForeignKey("BankAccount")]
27
+        public int? BankAccountId { get; set; }
25
 
28
 
29
+        public virtual Address Address { get; set; }
30
+        public virtual BankAccount BankAccount { get; set; }
26
         public virtual ICollection<Property> Properties { get; set; }
31
         public virtual ICollection<Property> Properties { get; set; }
27
         #endregion Properties
32
         #endregion Properties
28
     }
33
     }

+ 59
- 17
UnivateProperties_API/Repository/Timeshare/WeekRepository.cs View File

7
 using System.Net;
7
 using System.Net;
8
 using System.Text;
8
 using System.Text;
9
 using UnivateProperties_API.Containers.Timeshare;
9
 using UnivateProperties_API.Containers.Timeshare;
10
+using UnivateProperties_API.Containers.Timeshare.Detailed;
10
 using UnivateProperties_API.Containers.Users;
11
 using UnivateProperties_API.Containers.Users;
11
 using UnivateProperties_API.Context;
12
 using UnivateProperties_API.Context;
12
 using UnivateProperties_API.Helpers;
13
 using UnivateProperties_API.Helpers;
43
             return item;
44
             return item;
44
         }
45
         }
45
 
46
 
47
+        public DetailedWeekDto GetMyDetailed(Func<TimeshareWeek, bool> first)
48
+        {
49
+            var item = GetDetailed(first);
50
+            if(item != null)
51
+            {
52
+                return new DetailedWeekDto(item);
53
+            }
54
+            return null;
55
+        }
56
+
46
         public List<WeekDto> GetDtoListAll()
57
         public List<WeekDto> GetDtoListAll()
47
         {
58
         {
48
             List<WeekDto> list = new List<WeekDto>();
59
             List<WeekDto> list = new List<WeekDto>();
71
             }
82
             }
72
             else if (user.IsUserInRole(Role.Agency))
83
             else if (user.IsUserInRole(Role.Agency))
73
             {
84
             {
74
-                foreach (var item in GetDetailedAll().Where(x => x.AgencyId == userId))
85
+                var agent = _dbContext.Agents.FirstOrDefault(x => x.UserId == userId);
86
+                if(agent != null)
75
                 {
87
                 {
76
-                    list.Add(new WeekDto(item));
77
-                }
88
+                    foreach (var item in GetDetailedAll().Where(x => x.AgencyId == agent.AgencyId))
89
+                    {
90
+                        list.Add(new WeekDto(item));
91
+                    }
92
+                }                
78
             }
93
             }
79
             else if (user.IsUserInRole(Role.Agent) || user.IsUserInRole(Role.ManagingAgent))
94
             else if (user.IsUserInRole(Role.Agent) || user.IsUserInRole(Role.ManagingAgent))
80
             {
95
             {
81
-                foreach (var item in GetDetailedAll().Where(x => x.AgentId == userId))
96
+                var agent = _dbContext.Agents.FirstOrDefault(x => x.UserId == userId);
97
+                if(agent != null)
82
                 {
98
                 {
83
-                    list.Add(new WeekDto(item));
99
+                    foreach (var item in GetDetailedAll().Where(x => x.AgentId == agent.Id))
100
+                    {
101
+                        list.Add(new WeekDto(item));
102
+                    }
84
                 }
103
                 }
85
             }
104
             }
86
             else
105
             else
87
             {
106
             {
88
-                foreach (var item in GetDetailedAll().Where(x => x.OwnerId == userId))
107
+                var individual = _dbContext.Individuals.FirstOrDefault(x => x.UserId == userId);
108
+                if(individual != null)
89
                 {
109
                 {
90
-                    list.Add(new WeekDto(item));
91
-                }
110
+                    foreach (var item in GetDetailedAll().Where(x => x.OwnerId == userId))
111
+                    {
112
+                        list.Add(new WeekDto(item));
113
+                    }
114
+                }                
92
             }
115
             }
93
             return list;
116
             return list;
94
         }
117
         }
96
         public List<RegionDto> GetAvailResort()
119
         public List<RegionDto> GetAvailResort()
97
         {
120
         {
98
             List<RegionDto> list = new List<RegionDto>();
121
             List<RegionDto> list = new List<RegionDto>();
99
-            var allItems = GetDetailedAll();
122
+            var allItems = GetDtoListAll();
100
             foreach (var item in allItems)
123
             foreach (var item in allItems)
101
             {
124
             {
102
                 if (item.Region != null)
125
                 if (item.Region != null)
103
                 {
126
                 {
104
-                    if (!list.Any(x => x.RegionCode == item.Region.Code))
127
+                    if (!list.Any(x => x.RegionCode == item.Region.RegionCode))
105
                     {
128
                     {
106
-                        list.Add(new RegionDto(item.Region.Code, item.Region.Description));
129
+                        list.Add(new RegionDto(item.Region.RegionCode, item.Region.RegionName));
107
                     }
130
                     }
108
-                    foreach (var i in list.Where(x => x.RegionCode == item.Region.Code))
131
+                    foreach (var i in list.Where(x => x.RegionCode == item.Region.RegionCode))
109
                     {
132
                     {
110
-                        i.TryAddResort(item.ResortCode, item.ResortName);
133
+                        i.TryAddResort(item.Resort.ResortCode, item.Resort.ResortName);
111
                     }
134
                     }
112
                 }
135
                 }
113
             }
136
             }
117
                 region.OrderResorts();
140
                 region.OrderResorts();
118
                 foreach (var resort in region.Resorts)
141
                 foreach (var resort in region.Resorts)
119
                 {
142
                 {
120
-                    resort.Available = allItems.Count(x => x.ResortCode == resort.ResortCode);
143
+                    resort.Available = allItems.Count(x => x.Resort.ResortCode == resort.ResortCode);
121
                 }
144
                 }
122
             }
145
             }
123
             return list;
146
             return list;
192
                 };
215
                 };
193
             }
216
             }
194
             item.Id = NewId();
217
             item.Id = NewId();
218
+            UnivateProperties_API.Model.ProcessFlow.ProcessFlow flowItem = new Model.ProcessFlow.ProcessFlow()
219
+            {
220
+                Status = item.Status,
221
+                Timeshare = item
222
+            };
195
             _dbContext.Add(item);
223
             _dbContext.Add(item);
224
+            _dbContext.Add(flowItem);
196
             Save();
225
             Save();
197
         }
226
         }
198
 
227
 
282
             return id;
311
             return id;
283
         }
312
         }
284
 
313
 
314
+        private int _TenderId = 10000;
315
+        private int GetTenderId()
316
+        {
317
+            return _TenderId++;
318
+        }
319
+
285
         private List<WeekDto> GetTenderWeeks()
320
         private List<WeekDto> GetTenderWeeks()
286
         {
321
         {
287
             List<WeekDto> list = new List<WeekDto>();
322
             List<WeekDto> list = new List<WeekDto>();
299
                     foreach (string line in lines)
334
                     foreach (string line in lines)
300
                     {
335
                     {
301
                         cleanLine = line.Replace("<br>", "");
336
                         cleanLine = line.Replace("<br>", "");
302
-                        cleanLine = line.Replace("<br/>", "");
303
-                        list.Add(new WeekDto(cleanLine));
337
+                        cleanLine = cleanLine.Replace("<br >", "");
338
+                        cleanLine = cleanLine.Replace("<br/>", "");
339
+                        cleanLine = cleanLine.Replace("<br />", "");
340
+                        list.Add(new WeekDto(GetTenderId(),cleanLine));
304
                     }
341
                     }
305
                 }
342
                 }
306
             }
343
             }
320
             foreach(var item in list)
357
             foreach(var item in list)
321
             {
358
             {
322
                 prov = province.GetDetailed(x => x.Code == item.Region.RegionCode);
359
                 prov = province.GetDetailed(x => x.Code == item.Region.RegionCode);
323
-                item.Region = new RegionDto(prov.Id, prov.Code, prov.Description);
360
+                if(prov != null)
361
+                {
362
+                    item.Region = new RegionDto(prov.Id, prov.Code, prov.Description);
363
+                }                
324
             }
364
             }
325
             return list;
365
             return list;
326
         }
366
         }
331
             {
371
             {
332
                 case "FN":
372
                 case "FN":
333
                     return "KZN";
373
                     return "KZN";
374
+                case "L":
375
+                    return "LI";
334
                 default:
376
                 default:
335
                     return value;
377
                     return value;
336
             }
378
             }

Loading…
Cancel
Save