Bladeren bron

Added Added Is Deleted

Added get avail resort
master
Kobus 5 jaren geleden
bovenliggende
commit
bc398e31a8
38 gewijzigde bestanden met toevoegingen van 2047 en 170 verwijderingen
  1. 23
    3
      UnivateProperties_API/Containers/Timeshare/RegionDto.cs
  2. 67
    2
      UnivateProperties_API/Context/DataContext.cs
  3. 12
    0
      UnivateProperties_API/Controllers/Timeshare/TimeshareWeekController.cs
  4. 1
    2
      UnivateProperties_API/Controllers/Users/AgentController.cs
  5. 6
    70
      UnivateProperties_API/Controllers/Users/RegisterController.cs
  6. 1121
    0
      UnivateProperties_API/Migrations/20191003082255_IsDeleted.Designer.cs
  7. 321
    0
      UnivateProperties_API/Migrations/20191003082255_IsDeleted.cs
  8. 94
    3
      UnivateProperties_API/Migrations/DataContextModelSnapshot.cs
  9. 2
    1
      UnivateProperties_API/Model/BaseEntity.cs
  10. 1
    2
      UnivateProperties_API/Model/Users/User.cs
  11. 1
    1
      UnivateProperties_API/Program.cs
  12. 1
    1
      UnivateProperties_API/Properties/launchSettings.json
  13. 30
    0
      UnivateProperties_API/Repository/Banks/BankAccountRepository.cs
  14. 15
    0
      UnivateProperties_API/Repository/Communication/EmailRepository.cs
  15. 15
    0
      UnivateProperties_API/Repository/Communication/SMTPAccountRepository.cs
  16. 15
    0
      UnivateProperties_API/Repository/Communication/SMTPHostRepository.cs
  17. 1
    0
      UnivateProperties_API/Repository/IRepository.cs
  18. 6
    0
      UnivateProperties_API/Repository/Logging/SearchLogRepository.cs
  19. 6
    0
      UnivateProperties_API/Repository/ProccessFlow/BidRepository.cs
  20. 6
    0
      UnivateProperties_API/Repository/Properties/PropertyImageRepository.cs
  21. 7
    1
      UnivateProperties_API/Repository/Properties/PropertyRepository.cs
  22. 6
    0
      UnivateProperties_API/Repository/Properties/PropertyTypeRepository.cs
  23. 6
    0
      UnivateProperties_API/Repository/Properties/PropertyUserFieldRepository.cs
  24. 6
    0
      UnivateProperties_API/Repository/Properties/UserDefinedFieldRepository.cs
  25. 6
    0
      UnivateProperties_API/Repository/Properties/UserDefinedGroupRepository.cs
  26. 18
    3
      UnivateProperties_API/Repository/Region/CityRepository.cs
  27. 18
    3
      UnivateProperties_API/Repository/Region/ProvinceRepository.cs
  28. 18
    3
      UnivateProperties_API/Repository/Region/SuburbRepository.cs
  29. 15
    0
      UnivateProperties_API/Repository/Timeshare/SeasonRepository.cs
  30. 15
    0
      UnivateProperties_API/Repository/Timeshare/StatusRepository.cs
  31. 17
    0
      UnivateProperties_API/Repository/Timeshare/UnitConfigurationRepository.cs
  32. 43
    5
      UnivateProperties_API/Repository/Timeshare/WeekRepository.cs
  33. 19
    8
      UnivateProperties_API/Repository/Users/AgencyRepository.cs
  34. 16
    8
      UnivateProperties_API/Repository/Users/AgentRepository.cs
  35. 19
    1
      UnivateProperties_API/Repository/Users/IndividualRepository.cs
  36. 52
    36
      UnivateProperties_API/Repository/Users/RegisterRepository.cs
  37. 21
    16
      UnivateProperties_API/Repository/Users/UserRepository.cs
  38. 1
    1
      UnivateProperties_API/appsettings.json

+ 23
- 3
UnivateProperties_API/Containers/Timeshare/RegionDto.cs Bestand weergeven

@@ -1,21 +1,41 @@
1
-namespace UnivateProperties_API.Containers.Timeshare
1
+using System.Collections.Generic;
2
+using System.Linq;
3
+
4
+namespace UnivateProperties_API.Containers.Timeshare
2 5
 {
3 6
     public class RegionDto
4 7
     {
5 8
         public RegionDto()
6 9
         {
10
+            Resorts = new List<ResortDto>();
11
+        }
7 12
 
13
+        public RegionDto(string regionCode, string regionName)
14
+        {
15
+            RegionCode = regionCode;
16
+            RegionName = regionName;
17
+            Resorts = new List<ResortDto>();
8 18
         }
9 19
 
10
-        public RegionDto(int id, string regionName, string regionCode)
20
+        public RegionDto(int id, string regionCode, string regionName)
11 21
         {
12 22
             Id = id;
13
-            RegionName = regionName;
14 23
             RegionCode = regionCode;
24
+            RegionName = regionName;
25
+            Resorts = new List<ResortDto>();
15 26
         }
16 27
 
17 28
         public int Id { get; set; }
18 29
         public string RegionName { get; set; }
19 30
         public string RegionCode { get; set; }
31
+        public List<ResortDto> Resorts { get; set; }
32
+
33
+        public void TryAddResort(string resortCode, string resortName)
34
+        {
35
+            if (!Resorts.Any(x => x.ResortCode == resortCode))
36
+            {
37
+                Resorts.Add(new ResortDto(resortCode, resortName));
38
+            }
39
+        }
20 40
     }
21 41
 }

+ 67
- 2
UnivateProperties_API/Context/DataContext.cs Bestand weergeven

@@ -70,26 +70,91 @@ namespace UnivateProperties_API.Context
70 70
 
71 71
         public override int SaveChanges()
72 72
         {
73
-            foreach(var item in ChangeTracker
73
+            foreach (var item in ChangeTracker
74 74
                                     .Entries()
75 75
                                     .Where(x => x.State == EntityState.Modified || x.State == EntityState.Added)
76 76
                                     .Select(x => x.Entity)
77 77
                                     .ToList())
78 78
             {
79
-                if(item is BaseEntity)
79
+                if (item is BaseEntity)
80 80
                 {
81 81
                     (item as BaseEntity).UpdateModified(string.Empty);
82 82
                 }
83 83
             }
84
+            UpdateSoftDeleteStatuses();
84 85
             return base.SaveChanges();
85 86
         }
86 87
 
88
+        private void UpdateSoftDeleteStatuses()
89
+        {
90
+            foreach (var entry in ChangeTracker.Entries())
91
+            {
92
+                switch (entry.State)
93
+                {
94
+                    case EntityState.Added:
95
+                        entry.CurrentValues["IsDeleted"] = false;
96
+                        break;
97
+                    case EntityState.Deleted:
98
+                        entry.State = EntityState.Modified;
99
+                        entry.CurrentValues["IsDeleted"] = true;
100
+                        break;
101
+                }
102
+            }
103
+        }
104
+
87 105
         protected override void OnModelCreating(ModelBuilder modelBuilder)
88 106
         {
89 107
             modelBuilder.Entity<SMTPHost>().ToTable("Hosts");
90 108
             modelBuilder.Entity<UnitConfiguration>()
91 109
                 .HasIndex(u => u.Code)
92 110
                 .IsUnique();
111
+            modelBuilder.Entity<Individual>(b =>
112
+            {
113
+                b.HasKey(e => e.Id);
114
+                b.Property(e => e.Id).ValueGeneratedOnAdd();
115
+            });
116
+            modelBuilder.Entity<Agent>(b =>
117
+            {
118
+                b.HasKey(e => e.Id);
119
+                b.Property(e => e.Id).ValueGeneratedOnAdd();
120
+            });
121
+            modelBuilder.Entity<Agency>(b =>
122
+            {
123
+                b.HasKey(e => e.Id);
124
+                b.Property(e => e.Id).ValueGeneratedOnAdd();
125
+            });
126
+            modelBuilder.Entity<Person>(b =>
127
+            {
128
+                b.HasKey(e => e.Id);
129
+                b.Property(e => e.Id).ValueGeneratedOnAdd();
130
+            });
131
+            modelBuilder.Entity<Email>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
132
+            modelBuilder.Entity<SMTPAccount>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
133
+            modelBuilder.Entity<SMTPHost>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
134
+            modelBuilder.Entity<Property>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
135
+            modelBuilder.Entity<PropertyImage>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
136
+            modelBuilder.Entity<PropertyType>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
137
+            modelBuilder.Entity<PropertyUserField>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
138
+            modelBuilder.Entity<UserDefinedField>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
139
+            modelBuilder.Entity<UserDefinedGroup>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
140
+            modelBuilder.Entity<City>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
141
+            modelBuilder.Entity<Province>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
142
+            modelBuilder.Entity<Suburb>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
143
+            modelBuilder.Entity<Season>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
144
+            modelBuilder.Entity<Status>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
145
+            modelBuilder.Entity<TimeshareWeek>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
146
+            modelBuilder.Entity<UnitConfiguration>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
147
+            modelBuilder.Entity<UnitConfigurationType>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
148
+            modelBuilder.Entity<Agency>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
149
+            modelBuilder.Entity<Person>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
150
+            modelBuilder.Entity<User>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
151
+            modelBuilder.Entity<Bank>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
152
+            modelBuilder.Entity<BankAccount>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
153
+            modelBuilder.Entity<SearchLog>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
154
+            modelBuilder.Entity<Address>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
155
+            modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
156
+            modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
157
+
93 158
         }
94 159
     }
95 160
 }

+ 12
- 0
UnivateProperties_API/Controllers/Timeshare/TimeshareWeekController.cs Bestand weergeven

@@ -35,6 +35,18 @@ namespace UnivateProperties_API.Controllers.Timeshare
35 35
             return new OkObjectResult(item);
36 36
         }
37 37
 
38
+        [HttpGet("getAvailResort")]
39
+        public IActionResult GetAvailResort()
40
+        {
41
+            if (_Repo is WeekRepository)
42
+            {
43
+                var item = (_Repo as WeekRepository).GetAvailResort();
44
+                return new OkObjectResult(item);
45
+            }
46
+            else return new OkResult();
47
+
48
+        }
49
+
38 50
         [HttpGet("getBy")]
39 51
         public IActionResult GetBy(WeekFilterDto week)
40 52
         {

+ 1
- 2
UnivateProperties_API/Controllers/Users/AgentController.cs Bestand weergeven

@@ -36,8 +36,7 @@ namespace User_API.Controllers
36 36
             using (var scope = new TransactionScope())
37 37
             {
38 38
                 Agent agent = agentDto.Agent;
39
-                byte[] passwordHash, passwordSalt;
40
-                MyCommon.CreatePasswordHash(agentDto.Password, out passwordHash, out passwordSalt);
39
+                MyCommon.CreatePasswordHash(agentDto.Password, out byte[] passwordHash, out byte[] passwordSalt);
41 40
 
42 41
                 agent.User.PasswordHash = passwordHash;
43 42
                 agent.User.PasswordSalt = passwordSalt;

+ 6
- 70
UnivateProperties_API/Controllers/Users/RegisterController.cs Bestand weergeven

@@ -1,23 +1,16 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.IdentityModel.Tokens.Jwt;
4
-using System.Linq;
5
-using System.Security.Claims;
6
-using System.Text;
7
-using System.Threading.Tasks;
8
-using AutoMapper;
1
+using AutoMapper;
9 2
 using Microsoft.AspNetCore.Authorization;
10 3
 using Microsoft.AspNetCore.Mvc;
11 4
 using Microsoft.Extensions.Options;
12 5
 using Microsoft.IdentityModel.Tokens;
6
+using System;
7
+using System.IdentityModel.Tokens.Jwt;
8
+using System.Security.Claims;
9
+using System.Text;
13 10
 using UnivateProperties_API.Containers.Users;
14 11
 using UnivateProperties_API.Helpers;
15 12
 using UnivateProperties_API.Model.Users;
16
-using UnivateProperties_API.Repository;
17 13
 using UnivateProperties_API.Repository.Users;
18
-using System.Net.Http;
19
-using System.Net;
20
-using System.Web.Http;
21 14
 
22 15
 namespace UnivateProperties_API.Controllers.Users
23 16
 {
@@ -26,7 +19,7 @@ namespace UnivateProperties_API.Controllers.Users
26 19
     public class RegisterController : ControllerBase
27 20
     {
28 21
         private readonly IRegisterRepository _Repo;
29
-        private IMapper _mapper;
22
+        private readonly IMapper _mapper;
30 23
         private readonly AppSettings _appSettings;
31 24
 
32 25
         public RegisterController(IRegisterRepository repo, IMapper mapper, IOptions<AppSettings> appSettings)
@@ -108,62 +101,5 @@ namespace UnivateProperties_API.Controllers.Users
108 101
                 return BadRequest(new { message = ex.Message });
109 102
             }
110 103
         }
111
-
112
-        //[HttpGet("{id}")]
113
-        //public IActionResult GetById(int id)
114
-        //{
115
-        //    var user = _Repo.GetById(id);
116
-        //    var userDto = _mapper.Map<UserDto>(user);
117
-
118
-        //    if (user == null)
119
-        //    {
120
-        //        return NotFound();
121
-        //    }
122
-
123
-        //    // Only allow SuperAdmins to access other user records
124
-        //    var currentUserId = int.Parse(User.Identity.Name);
125
-        //    if (id != currentUserId && !User.IsInRole(Role.SuperAdmin))
126
-        //    {
127
-        //        return Forbid();
128
-        //    }
129
-
130
-        //    return Ok(userDto);
131
-        //}
132
-
133
-        //[HttpGet("{id}")]
134
-        //public IActionResult GetByAgencyId(int id)
135
-        //{
136
-        //    var agency = _Repo.GetByAgencyId(id);
137
-        //    var agencyDto = _mapper.Map<AgencyDto>(agency);
138
-
139
-        //    if (agency == null)
140
-        //    {
141
-        //        return NotFound();
142
-        //    }
143
-
144
-        //    var currentAgencyId = int.Parse(User.Identity.Name);
145
-        //    if (id != currentAgencyId && !User.IsInRole(Role.Agency))
146
-        //    {
147
-        //        return Forbid();
148
-        //    }
149
-
150
-        //    return Ok(agencyDto);
151
-        //}
152
-
153
-        //[Authorize(Roles = Role.SuperAdmin)]
154
-        //[HttpDelete("{id}")]
155
-        //public IActionResult Delete(User user)
156
-        //{
157
-        //    _Repo.Delete(user.Id);
158
-        //    return Ok();
159
-        //}
160
-
161
-        //[Authorize(Roles = Role.SuperAdmin)]
162
-        //[HttpDelete("{id}")]
163
-        //public IActionResult DeleteAgency(Agency agency)
164
-        //{
165
-        //    _Repo.DeleteAgency(agency.Id);
166
-        //    return Ok();
167
-        //}
168 104
     }
169 105
 }

+ 1121
- 0
UnivateProperties_API/Migrations/20191003082255_IsDeleted.Designer.cs
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 321
- 0
UnivateProperties_API/Migrations/20191003082255_IsDeleted.cs Bestand weergeven

@@ -0,0 +1,321 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
+
5
+namespace UnivateProperties_API.Migrations
6
+{
7
+    public partial class IsDeleted : Migration
8
+    {
9
+        protected override void Up(MigrationBuilder migrationBuilder)
10
+        {
11
+            migrationBuilder.AddColumn<bool>(
12
+                name: "IsDeleted",
13
+                table: "Weeks",
14
+                nullable: false,
15
+                defaultValue: false);
16
+
17
+            migrationBuilder.AddColumn<bool>(
18
+                name: "IsDeleted",
19
+                table: "Users",
20
+                nullable: false,
21
+                defaultValue: false);
22
+
23
+            migrationBuilder.AddColumn<bool>(
24
+                name: "IsDeleted",
25
+                table: "UserDefinedGroups",
26
+                nullable: false,
27
+                defaultValue: false);
28
+
29
+            migrationBuilder.AddColumn<bool>(
30
+                name: "IsDeleted",
31
+                table: "UserDefinedFields",
32
+                nullable: false,
33
+                defaultValue: false);
34
+
35
+            migrationBuilder.AddColumn<bool>(
36
+                name: "IsDeleted",
37
+                table: "UnitConfigurationTypes",
38
+                nullable: false,
39
+                defaultValue: false);
40
+
41
+            migrationBuilder.AddColumn<bool>(
42
+                name: "IsDeleted",
43
+                table: "UnitConfigurations",
44
+                nullable: false,
45
+                defaultValue: false);
46
+
47
+            migrationBuilder.AddColumn<bool>(
48
+                name: "IsDeleted",
49
+                table: "Suburbs",
50
+                nullable: false,
51
+                defaultValue: false);
52
+
53
+            migrationBuilder.AddColumn<bool>(
54
+                name: "IsDeleted",
55
+                table: "Status",
56
+                nullable: false,
57
+                defaultValue: false);
58
+
59
+            migrationBuilder.AddColumn<bool>(
60
+                name: "IsDeleted",
61
+                table: "Seasons",
62
+                nullable: false,
63
+                defaultValue: false);
64
+
65
+            migrationBuilder.AddColumn<bool>(
66
+                name: "IsDeleted",
67
+                table: "SearchLogs",
68
+                nullable: false,
69
+                defaultValue: false);
70
+
71
+            migrationBuilder.AddColumn<bool>(
72
+                name: "IsDeleted",
73
+                table: "Provinces",
74
+                nullable: false,
75
+                defaultValue: false);
76
+
77
+            migrationBuilder.AddColumn<bool>(
78
+                name: "IsDeleted",
79
+                table: "PropertyUserFields",
80
+                nullable: false,
81
+                defaultValue: false);
82
+
83
+            migrationBuilder.AddColumn<bool>(
84
+                name: "IsDeleted",
85
+                table: "PropertyTypes",
86
+                nullable: false,
87
+                defaultValue: false);
88
+
89
+            migrationBuilder.AddColumn<bool>(
90
+                name: "IsDeleted",
91
+                table: "PropertyImages",
92
+                nullable: false,
93
+                defaultValue: false);
94
+
95
+            migrationBuilder.AddColumn<bool>(
96
+                name: "IsDeleted",
97
+                table: "Properties",
98
+                nullable: false,
99
+                defaultValue: false);
100
+
101
+            migrationBuilder.AddColumn<bool>(
102
+                name: "IsDeleted",
103
+                table: "ProcessFlows",
104
+                nullable: false,
105
+                defaultValue: false);
106
+
107
+            migrationBuilder.AddColumn<bool>(
108
+                name: "IsDeleted",
109
+                table: "Individuals",
110
+                nullable: false,
111
+                defaultValue: false);
112
+
113
+            migrationBuilder.AddColumn<bool>(
114
+                name: "IsDeleted",
115
+                table: "Hosts",
116
+                nullable: false,
117
+                defaultValue: false);
118
+
119
+            migrationBuilder.AddColumn<bool>(
120
+                name: "IsDeleted",
121
+                table: "Emails",
122
+                nullable: false,
123
+                defaultValue: false);
124
+
125
+            migrationBuilder.AddColumn<bool>(
126
+                name: "IsDeleted",
127
+                table: "Cities",
128
+                nullable: false,
129
+                defaultValue: false);
130
+
131
+            migrationBuilder.AddColumn<bool>(
132
+                name: "IsDeleted",
133
+                table: "BidItems",
134
+                nullable: false,
135
+                defaultValue: false);
136
+
137
+            migrationBuilder.AddColumn<bool>(
138
+                name: "IsDeleted",
139
+                table: "Banks",
140
+                nullable: false,
141
+                defaultValue: false);
142
+
143
+            migrationBuilder.AddColumn<bool>(
144
+                name: "IsDeleted",
145
+                table: "BankAccounts",
146
+                nullable: false,
147
+                defaultValue: false);
148
+
149
+            migrationBuilder.AddColumn<bool>(
150
+                name: "IsDeleted",
151
+                table: "Agents",
152
+                nullable: false,
153
+                defaultValue: false);
154
+
155
+            migrationBuilder.AddColumn<bool>(
156
+                name: "IsDeleted",
157
+                table: "Agencies",
158
+                nullable: false,
159
+                defaultValue: false);
160
+
161
+            migrationBuilder.AddColumn<bool>(
162
+                name: "IsDeleted",
163
+                table: "Addresses",
164
+                nullable: false,
165
+                defaultValue: false);
166
+
167
+            migrationBuilder.AddColumn<bool>(
168
+                name: "IsDeleted",
169
+                table: "Accounts",
170
+                nullable: false,
171
+                defaultValue: false);
172
+
173
+            migrationBuilder.CreateTable(
174
+                name: "Person",
175
+                columns: table => new
176
+                {
177
+                    Id = table.Column<int>(nullable: false)
178
+                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
179
+                    Created = table.Column<DateTime>(nullable: false),
180
+                    Modified = table.Column<DateTime>(nullable: false),
181
+                    ModifiedBy = table.Column<string>(nullable: true),
182
+                    IsDeleted = table.Column<bool>(nullable: false),
183
+                    UserId = table.Column<int>(nullable: true),
184
+                    Name = table.Column<string>(nullable: true),
185
+                    Surname = table.Column<string>(nullable: true),
186
+                    Email = table.Column<string>(nullable: true),
187
+                    Telephone = table.Column<string>(nullable: true),
188
+                    CellNumber = table.Column<string>(nullable: true)
189
+                },
190
+                constraints: table =>
191
+                {
192
+                    table.PrimaryKey("PK_Person", x => x.Id);
193
+                    table.ForeignKey(
194
+                        name: "FK_Person_Users_UserId",
195
+                        column: x => x.UserId,
196
+                        principalTable: "Users",
197
+                        principalColumn: "Id",
198
+                        onDelete: ReferentialAction.Restrict);
199
+                });
200
+
201
+            migrationBuilder.CreateIndex(
202
+                name: "IX_Person_UserId",
203
+                table: "Person",
204
+                column: "UserId");
205
+        }
206
+
207
+        protected override void Down(MigrationBuilder migrationBuilder)
208
+        {
209
+            migrationBuilder.DropTable(
210
+                name: "Person");
211
+
212
+            migrationBuilder.DropColumn(
213
+                name: "IsDeleted",
214
+                table: "Weeks");
215
+
216
+            migrationBuilder.DropColumn(
217
+                name: "IsDeleted",
218
+                table: "Users");
219
+
220
+            migrationBuilder.DropColumn(
221
+                name: "IsDeleted",
222
+                table: "UserDefinedGroups");
223
+
224
+            migrationBuilder.DropColumn(
225
+                name: "IsDeleted",
226
+                table: "UserDefinedFields");
227
+
228
+            migrationBuilder.DropColumn(
229
+                name: "IsDeleted",
230
+                table: "UnitConfigurationTypes");
231
+
232
+            migrationBuilder.DropColumn(
233
+                name: "IsDeleted",
234
+                table: "UnitConfigurations");
235
+
236
+            migrationBuilder.DropColumn(
237
+                name: "IsDeleted",
238
+                table: "Suburbs");
239
+
240
+            migrationBuilder.DropColumn(
241
+                name: "IsDeleted",
242
+                table: "Status");
243
+
244
+            migrationBuilder.DropColumn(
245
+                name: "IsDeleted",
246
+                table: "Seasons");
247
+
248
+            migrationBuilder.DropColumn(
249
+                name: "IsDeleted",
250
+                table: "SearchLogs");
251
+
252
+            migrationBuilder.DropColumn(
253
+                name: "IsDeleted",
254
+                table: "Provinces");
255
+
256
+            migrationBuilder.DropColumn(
257
+                name: "IsDeleted",
258
+                table: "PropertyUserFields");
259
+
260
+            migrationBuilder.DropColumn(
261
+                name: "IsDeleted",
262
+                table: "PropertyTypes");
263
+
264
+            migrationBuilder.DropColumn(
265
+                name: "IsDeleted",
266
+                table: "PropertyImages");
267
+
268
+            migrationBuilder.DropColumn(
269
+                name: "IsDeleted",
270
+                table: "Properties");
271
+
272
+            migrationBuilder.DropColumn(
273
+                name: "IsDeleted",
274
+                table: "ProcessFlows");
275
+
276
+            migrationBuilder.DropColumn(
277
+                name: "IsDeleted",
278
+                table: "Individuals");
279
+
280
+            migrationBuilder.DropColumn(
281
+                name: "IsDeleted",
282
+                table: "Hosts");
283
+
284
+            migrationBuilder.DropColumn(
285
+                name: "IsDeleted",
286
+                table: "Emails");
287
+
288
+            migrationBuilder.DropColumn(
289
+                name: "IsDeleted",
290
+                table: "Cities");
291
+
292
+            migrationBuilder.DropColumn(
293
+                name: "IsDeleted",
294
+                table: "BidItems");
295
+
296
+            migrationBuilder.DropColumn(
297
+                name: "IsDeleted",
298
+                table: "Banks");
299
+
300
+            migrationBuilder.DropColumn(
301
+                name: "IsDeleted",
302
+                table: "BankAccounts");
303
+
304
+            migrationBuilder.DropColumn(
305
+                name: "IsDeleted",
306
+                table: "Agents");
307
+
308
+            migrationBuilder.DropColumn(
309
+                name: "IsDeleted",
310
+                table: "Agencies");
311
+
312
+            migrationBuilder.DropColumn(
313
+                name: "IsDeleted",
314
+                table: "Addresses");
315
+
316
+            migrationBuilder.DropColumn(
317
+                name: "IsDeleted",
318
+                table: "Accounts");
319
+        }
320
+    }
321
+}

+ 94
- 3
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs Bestand weergeven

@@ -16,7 +16,7 @@ namespace UnivateProperties_API.Migrations
16 16
 #pragma warning disable 612, 618
17 17
             modelBuilder
18 18
                 .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
19
-                .HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
19
+                .HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
20 20
                 .HasAnnotation("Relational:MaxIdentifierLength", 63);
21 21
 
22 22
             modelBuilder.Entity("UnivateProperties_API.Model.Banks.Bank", b =>
@@ -26,6 +26,8 @@ namespace UnivateProperties_API.Migrations
26 26
 
27 27
                     b.Property<DateTime>("Created");
28 28
 
29
+                    b.Property<bool>("IsDeleted");
30
+
29 31
                     b.Property<DateTime>("Modified");
30 32
 
31 33
                     b.Property<string>("ModifiedBy");
@@ -52,6 +54,8 @@ namespace UnivateProperties_API.Migrations
52 54
 
53 55
                     b.Property<DateTime>("Created");
54 56
 
57
+                    b.Property<bool>("IsDeleted");
58
+
55 59
                     b.Property<DateTime>("Modified");
56 60
 
57 61
                     b.Property<string>("ModifiedBy");
@@ -84,6 +88,8 @@ namespace UnivateProperties_API.Migrations
84 88
 
85 89
                     b.Property<bool>("IsBodyHtml");
86 90
 
91
+                    b.Property<bool>("IsDeleted");
92
+
87 93
                     b.Property<DateTime>("Modified");
88 94
 
89 95
                     b.Property<string>("ModifiedBy");
@@ -114,6 +120,8 @@ namespace UnivateProperties_API.Migrations
114 120
 
115 121
                     b.Property<string>("DisplayName");
116 122
 
123
+                    b.Property<bool>("IsDeleted");
124
+
117 125
                     b.Property<DateTime>("Modified");
118 126
 
119 127
                     b.Property<string>("ModifiedBy");
@@ -136,6 +144,8 @@ namespace UnivateProperties_API.Migrations
136 144
 
137 145
                     b.Property<string>("Host");
138 146
 
147
+                    b.Property<bool>("IsDeleted");
148
+
139 149
                     b.Property<DateTime>("Modified");
140 150
 
141 151
                     b.Property<string>("ModifiedBy");
@@ -160,13 +170,15 @@ namespace UnivateProperties_API.Migrations
160 170
 
161 171
                     b.Property<DateTime>("Created");
162 172
 
173
+                    b.Property<bool>("IsDeleted");
174
+
163 175
                     b.Property<DateTime>("Modified");
164 176
 
165 177
                     b.Property<string>("ModifiedBy");
166 178
 
167 179
                     b.Property<string>("Search");
168 180
 
169
-                    b.Property<int?>("UserID");
181
+                    b.Property<string>("Type");
170 182
 
171 183
                     b.HasKey("Id");
172 184
 
@@ -182,6 +194,8 @@ namespace UnivateProperties_API.Migrations
182 194
 
183 195
                     b.Property<DateTime>("Created");
184 196
 
197
+                    b.Property<bool>("IsDeleted");
198
+
185 199
                     b.Property<DateTime>("Modified");
186 200
 
187 201
                     b.Property<string>("ModifiedBy");
@@ -214,6 +228,8 @@ namespace UnivateProperties_API.Migrations
214 228
 
215 229
                     b.Property<string>("DeclinedReason");
216 230
 
231
+                    b.Property<bool>("IsDeleted");
232
+
217 233
                     b.Property<DateTime>("Modified");
218 234
 
219 235
                     b.Property<string>("ModifiedBy");
@@ -244,6 +260,8 @@ namespace UnivateProperties_API.Migrations
244 260
 
245 261
                     b.Property<DateTime>("Created");
246 262
 
263
+                    b.Property<bool>("IsDeleted");
264
+
247 265
                     b.Property<DateTime>("Modified");
248 266
 
249 267
                     b.Property<string>("ModifiedBy");
@@ -286,7 +304,7 @@ namespace UnivateProperties_API.Migrations
286 304
 
287 305
                     b.Property<string>("Description");
288 306
 
289
-                    b.Property<int?>("GCRecord");
307
+                    b.Property<bool>("IsDeleted");
290 308
 
291 309
                     b.Property<bool>("IsSale");
292 310
 
@@ -350,6 +368,8 @@ namespace UnivateProperties_API.Migrations
350 368
 
351 369
                     b.Property<bool>("IsDefault");
352 370
 
371
+                    b.Property<bool>("IsDeleted");
372
+
353 373
                     b.Property<DateTime>("Modified");
354 374
 
355 375
                     b.Property<string>("ModifiedBy");
@@ -372,6 +392,8 @@ namespace UnivateProperties_API.Migrations
372 392
 
373 393
                     b.Property<string>("Description");
374 394
 
395
+                    b.Property<bool>("IsDeleted");
396
+
375 397
                     b.Property<DateTime>("Modified");
376 398
 
377 399
                     b.Property<string>("ModifiedBy");
@@ -392,6 +414,8 @@ namespace UnivateProperties_API.Migrations
392 414
 
393 415
                     b.Property<string>("Description");
394 416
 
417
+                    b.Property<bool>("IsDeleted");
418
+
395 419
                     b.Property<DateTime>("Modified");
396 420
 
397 421
                     b.Property<string>("ModifiedBy");
@@ -424,6 +448,8 @@ namespace UnivateProperties_API.Migrations
424 448
 
425 449
                     b.Property<int>("GroupId");
426 450
 
451
+                    b.Property<bool>("IsDeleted");
452
+
427 453
                     b.Property<DateTime>("Modified");
428 454
 
429 455
                     b.Property<string>("ModifiedBy");
@@ -446,6 +472,8 @@ namespace UnivateProperties_API.Migrations
446 472
 
447 473
                     b.Property<string>("Description");
448 474
 
475
+                    b.Property<bool>("IsDeleted");
476
+
449 477
                     b.Property<DateTime>("Modified");
450 478
 
451 479
                     b.Property<string>("ModifiedBy");
@@ -470,6 +498,8 @@ namespace UnivateProperties_API.Migrations
470 498
 
471 499
                     b.Property<string>("Description");
472 500
 
501
+                    b.Property<bool>("IsDeleted");
502
+
473 503
                     b.Property<DateTime>("Modified");
474 504
 
475 505
                     b.Property<string>("ModifiedBy");
@@ -494,6 +524,8 @@ namespace UnivateProperties_API.Migrations
494 524
 
495 525
                     b.Property<string>("Description");
496 526
 
527
+                    b.Property<bool>("IsDeleted");
528
+
497 529
                     b.Property<DateTime>("Modified");
498 530
 
499 531
                     b.Property<string>("ModifiedBy");
@@ -514,6 +546,8 @@ namespace UnivateProperties_API.Migrations
514 546
 
515 547
                     b.Property<string>("Description");
516 548
 
549
+                    b.Property<bool>("IsDeleted");
550
+
517 551
                     b.Property<DateTime>("Modified");
518 552
 
519 553
                     b.Property<string>("ModifiedBy");
@@ -534,6 +568,8 @@ namespace UnivateProperties_API.Migrations
534 568
 
535 569
                     b.Property<DateTime>("Created");
536 570
 
571
+                    b.Property<bool>("IsDeleted");
572
+
537 573
                     b.Property<DateTime>("Modified");
538 574
 
539 575
                     b.Property<string>("ModifiedBy");
@@ -556,6 +592,8 @@ namespace UnivateProperties_API.Migrations
556 592
 
557 593
                     b.Property<string>("Description");
558 594
 
595
+                    b.Property<bool>("IsDeleted");
596
+
559 597
                     b.Property<DateTime>("Modified");
560 598
 
561 599
                     b.Property<string>("ModifiedBy");
@@ -590,6 +628,8 @@ namespace UnivateProperties_API.Migrations
590 628
 
591 629
                     b.Property<DateTime>("DepartureDate");
592 630
 
631
+                    b.Property<bool>("IsDeleted");
632
+
593 633
                     b.Property<bool>("LeviesPaidInFull");
594 634
 
595 635
                     b.Property<double>("LevyAmount");
@@ -660,6 +700,8 @@ namespace UnivateProperties_API.Migrations
660 700
 
661 701
                     b.Property<DateTime>("Created");
662 702
 
703
+                    b.Property<bool>("IsDeleted");
704
+
663 705
                     b.Property<DateTime>("Modified");
664 706
 
665 707
                     b.Property<string>("ModifiedBy");
@@ -681,6 +723,8 @@ namespace UnivateProperties_API.Migrations
681 723
 
682 724
                     b.Property<string>("Description");
683 725
 
726
+                    b.Property<bool>("IsDeleted");
727
+
684 728
                     b.Property<DateTime>("Modified");
685 729
 
686 730
                     b.Property<string>("ModifiedBy");
@@ -707,6 +751,8 @@ namespace UnivateProperties_API.Migrations
707 751
 
708 752
                     b.Property<string>("EAABEFFCNumber");
709 753
 
754
+                    b.Property<bool>("IsDeleted");
755
+
710 756
                     b.Property<DateTime>("Modified");
711 757
 
712 758
                     b.Property<string>("ModifiedBy");
@@ -729,6 +775,8 @@ namespace UnivateProperties_API.Migrations
729 775
 
730 776
                     b.Property<string>("Email");
731 777
 
778
+                    b.Property<bool>("IsDeleted");
779
+
732 780
                     b.Property<DateTime>("Modified");
733 781
 
734 782
                     b.Property<string>("ModifiedBy");
@@ -769,6 +817,8 @@ namespace UnivateProperties_API.Migrations
769 817
 
770 818
                     b.Property<string>("IncomeTaxNumber");
771 819
 
820
+                    b.Property<bool>("IsDeleted");
821
+
772 822
                     b.Property<string>("MaritalStatus");
773 823
 
774 824
                     b.Property<DateTime>("Modified");
@@ -792,6 +842,38 @@ namespace UnivateProperties_API.Migrations
792 842
                     b.ToTable("Individuals");
793 843
                 });
794 844
 
845
+            modelBuilder.Entity("UnivateProperties_API.Model.Users.Person", b =>
846
+                {
847
+                    b.Property<int>("Id")
848
+                        .ValueGeneratedOnAdd();
849
+
850
+                    b.Property<string>("CellNumber");
851
+
852
+                    b.Property<DateTime>("Created");
853
+
854
+                    b.Property<string>("Email");
855
+
856
+                    b.Property<bool>("IsDeleted");
857
+
858
+                    b.Property<DateTime>("Modified");
859
+
860
+                    b.Property<string>("ModifiedBy");
861
+
862
+                    b.Property<string>("Name");
863
+
864
+                    b.Property<string>("Surname");
865
+
866
+                    b.Property<string>("Telephone");
867
+
868
+                    b.Property<int?>("UserId");
869
+
870
+                    b.HasKey("Id");
871
+
872
+                    b.HasIndex("UserId");
873
+
874
+                    b.ToTable("Person");
875
+                });
876
+
795 877
             modelBuilder.Entity("UnivateProperties_API.Model.Users.User", b =>
796 878
                 {
797 879
                     b.Property<int>("Id")
@@ -799,6 +881,8 @@ namespace UnivateProperties_API.Migrations
799 881
 
800 882
                     b.Property<DateTime>("Created");
801 883
 
884
+                    b.Property<bool>("IsDeleted");
885
+
802 886
                     b.Property<DateTime>("Modified");
803 887
 
804 888
                     b.Property<string>("ModifiedBy");
@@ -1022,6 +1106,13 @@ namespace UnivateProperties_API.Migrations
1022 1106
                         .WithMany()
1023 1107
                         .HasForeignKey("UserId");
1024 1108
                 });
1109
+
1110
+            modelBuilder.Entity("UnivateProperties_API.Model.Users.Person", b =>
1111
+                {
1112
+                    b.HasOne("UnivateProperties_API.Model.Users.User", "User")
1113
+                        .WithMany()
1114
+                        .HasForeignKey("UserId");
1115
+                });
1025 1116
 #pragma warning restore 612, 618
1026 1117
         }
1027 1118
     }

+ 2
- 1
UnivateProperties_API/Model/BaseEntity.cs Bestand weergeven

@@ -5,7 +5,7 @@ using UnivateProperties_API.Containers;
5 5
 
6 6
 namespace UnivateProperties_API.Model
7 7
 {
8
-    public abstract class BaseEntity
8
+    public class BaseEntity
9 9
     {
10 10
         #region Properties
11 11
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -16,6 +16,7 @@ namespace UnivateProperties_API.Model
16 16
         public string ModifiedBy { get; set; }
17 17
         [NotMapped]
18 18
         public ValidateEntity Valid { get; set; }
19
+        public bool IsDeleted { get; set; } = false;
19 20
         #endregion
20 21
 
21 22
         #region Methods

+ 1
- 2
UnivateProperties_API/Model/Users/User.cs Bestand weergeven

@@ -9,8 +9,7 @@ namespace UnivateProperties_API.Model.Users
9 9
         {
10 10
             Username = username;
11 11
 
12
-            byte[] passwordHash, passwordSalt;
13
-            MyCommon.CreatePasswordHash(password, out passwordHash, out passwordSalt);
12
+            MyCommon.CreatePasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt);
14 13
 
15 14
             PasswordHash = passwordHash;
16 15
             PasswordSalt = passwordSalt;

+ 1
- 1
UnivateProperties_API/Program.cs Bestand weergeven

@@ -18,7 +18,7 @@ namespace UnivateProperties_API
18 18
         public static IWebHost BuildWebHost(string[] args) =>
19 19
             WebHost.CreateDefaultBuilder(args)
20 20
                 .UseStartup<Startup>()
21
-                .UseUrls("http://192.168.6.188/Univate-API")
21
+                .UseUrls("http://192.168.6.188:5000")
22 22
                 .Build();
23 23
     }
24 24
 }

+ 1
- 1
UnivateProperties_API/Properties/launchSettings.json Bestand weergeven

@@ -24,7 +24,7 @@
24 24
       "environmentVariables": {
25 25
         "ASPNETCORE_ENVIRONMENT": "Development"
26 26
       },
27
-      "applicationUrl": "http://localhost:5000"
27
+      "applicationUrl": "http://192.168.6.188:5000"
28 28
     }
29 29
   }
30 30
 }

+ 30
- 0
UnivateProperties_API/Repository/Banks/BankAccountRepository.cs Bestand weergeven

@@ -51,30 +51,38 @@ namespace UnivateProperties_API.Repository.Banks
51 51
 
52 52
         public void Insert(Bank item)
53 53
         {
54
+            item.Id = NewBankId();
54 55
             _dbContext.Add(item);
55 56
             Save();
56 57
         }
57 58
 
58 59
         public void Insert(IEnumerable<Bank> items)
59 60
         {
61
+            int id = NewBankId();
60 62
             foreach (var item in items)
61 63
             {
64
+                item.Id = id;
62 65
                 _dbContext.Add(item);
66
+                id += 1;
63 67
             }
64 68
             Save();
65 69
         }
66 70
 
67 71
         public void Insert(BankAccount item)
68 72
         {
73
+            item.Id = NewId();
69 74
             _dbContext.Add(item);
70 75
             Save();
71 76
         }
72 77
 
73 78
         public void Insert(IEnumerable<BankAccount> items)
74 79
         {
80
+            int id = NewId();
75 81
             foreach (var item in items)
76 82
             {
83
+                item.Id = id;
77 84
                 _dbContext.Add(item);
85
+                id += 1;
78 86
             }
79 87
             Save();
80 88
         }
@@ -146,5 +154,27 @@ namespace UnivateProperties_API.Repository.Banks
146 154
         {
147 155
             return _dbContext.BankAccounts.ToList();
148 156
         }
157
+
158
+        public int NewId()
159
+        {
160
+            int id = 0;
161
+            if (_dbContext.BankAccounts.Count() > 0)
162
+            {
163
+                _dbContext.BankAccounts.Max(x => x.Id);
164
+            }
165
+            id += 1;
166
+            return id;
167
+        }
168
+
169
+        public int NewBankId()
170
+        {
171
+            int id = 0;
172
+            if (_dbContext.Banks.Count() > 0)
173
+            {
174
+                _dbContext.Banks.Max(x => x.Id);
175
+            }
176
+            id += 1;
177
+            return id;
178
+        }
149 179
     }
150 180
 }

+ 15
- 0
UnivateProperties_API/Repository/Communication/EmailRepository.cs Bestand weergeven

@@ -55,6 +55,7 @@ namespace UnivateProperties_API.Repository.Communication
55 55
         {
56 56
             SMTPAccountRepository account = new SMTPAccountRepository(_dbContext);
57 57
             item = GetDetailedObject(item, account);
58
+            item.Id = NewId();
58 59
             item.SendMail();
59 60
             _dbContext.Add(item);
60 61
             Save();
@@ -62,10 +63,13 @@ namespace UnivateProperties_API.Repository.Communication
62 63
 
63 64
         public void Insert(IEnumerable<Email> items)
64 65
         {
66
+            int id = NewId();
65 67
             foreach (var item in items)
66 68
             {
69
+                item.Id = id;
67 70
                 item.SendMail();
68 71
                 _dbContext.Add(item);
72
+                id += 1;
69 73
             }
70 74
             Save();
71 75
         }
@@ -104,5 +108,16 @@ namespace UnivateProperties_API.Repository.Communication
104 108
         {
105 109
             _dbContext.SaveChanges();
106 110
         }
111
+
112
+        public int NewId()
113
+        {
114
+            int id = 0;
115
+            if (_dbContext.Emails.Count() > 0)
116
+            {
117
+                id = _dbContext.Emails.Max(x => x.Id);
118
+            }
119
+            id += 1;
120
+            return id;
121
+        }
107 122
     }
108 123
 }

+ 15
- 0
UnivateProperties_API/Repository/Communication/SMTPAccountRepository.cs Bestand weergeven

@@ -47,15 +47,19 @@ namespace UnivateProperties_API.Repository.Communication
47 47
 
48 48
         public void Insert(SMTPAccount item)
49 49
         {
50
+            item.Id = NewId();
50 51
             _dbContext.Add(item);
51 52
             Save();
52 53
         }
53 54
 
54 55
         public void Insert(IEnumerable<SMTPAccount> items)
55 56
         {
57
+            int id = NewId();
56 58
             foreach (var item in items)
57 59
             {
60
+                item.Id = id;
58 61
                 _dbContext.Add(item);
62
+                id += 1;
59 63
             }
60 64
             Save();
61 65
         }
@@ -94,5 +98,16 @@ namespace UnivateProperties_API.Repository.Communication
94 98
         {
95 99
             _dbContext.SaveChanges();
96 100
         }
101
+
102
+        public int NewId()
103
+        {
104
+            int id = 0;
105
+            if (_dbContext.Accounts.Count() > 0)
106
+            {
107
+                id = _dbContext.Accounts.Max(x => x.Id);
108
+            }
109
+            id += 1;
110
+            return id;
111
+        }
97 112
     }
98 113
 }

+ 15
- 0
UnivateProperties_API/Repository/Communication/SMTPHostRepository.cs Bestand weergeven

@@ -38,15 +38,19 @@ namespace UnivateProperties_API.Repository.Communication
38 38
 
39 39
         public void Insert(SMTPHost item)
40 40
         {
41
+            item.Id = NewId();
41 42
             _dbContext.Add(item);
42 43
             Save();
43 44
         }
44 45
 
45 46
         public void Insert(IEnumerable<SMTPHost> items)
46 47
         {
48
+            int id = NewId();
47 49
             foreach (var item in items)
48 50
             {
51
+                item.Id = id;
49 52
                 _dbContext.Add(item);
53
+                id += 1;
50 54
             }
51 55
             Save();
52 56
         }
@@ -85,5 +89,16 @@ namespace UnivateProperties_API.Repository.Communication
85 89
         {
86 90
             _dbContext.SaveChanges();
87 91
         }
92
+
93
+        public int NewId()
94
+        {
95
+            int id = 0;
96
+            if (_dbContext.Hosts.Count() > 0)
97
+            {
98
+                id = _dbContext.Hosts.Max(x => x.Id);
99
+            }
100
+            id += 1;
101
+            return id;
102
+        }
88 103
     }
89 104
 }

+ 1
- 0
UnivateProperties_API/Repository/IRepository.cs Bestand weergeven

@@ -16,6 +16,7 @@ namespace UnivateProperties_API.Repository
16 16
         void Remove(IEnumerable<TEntity> items);
17 17
         void RemoveAtId(int item);
18 18
         void Update(TEntity item);
19
+        int NewId();
19 20
         void Save();
20 21
     }
21 22
 }

+ 6
- 0
UnivateProperties_API/Repository/Logging/SearchLogRepository.cs Bestand weergeven

@@ -143,5 +143,11 @@ namespace UnivateProperties_API.Repository.Logging
143 143
             _dbContext.Entry(item).State = EntityState.Modified;
144 144
             Save();
145 145
         }
146
+
147
+        public int NewId()
148
+        {
149
+            // Not sure if properties need it
150
+            return 0;
151
+        }
146 152
     }
147 153
 }

+ 6
- 0
UnivateProperties_API/Repository/ProccessFlow/BidRepository.cs Bestand weergeven

@@ -215,5 +215,11 @@ namespace UnivateProperties_API.Repository.ProccessFlow
215 215
             List<BidItem> bids = new List<BidItem>() { bid };
216 216
             return LoadDisplay(bids).Find(x => x.Id == bid.Id);
217 217
         }
218
+
219
+        public int NewId()
220
+        {
221
+            // Not sure if properties need it
222
+            return 0;
223
+        }
218 224
     }
219 225
 }

+ 6
- 0
UnivateProperties_API/Repository/Properties/PropertyImageRepository.cs Bestand weergeven

@@ -94,5 +94,11 @@ namespace UnivateProperties_API.Repository.Properties
94 94
             dBContext.Entry(item).State = EntityState.Modified;
95 95
             Save();
96 96
         }
97
+
98
+        public int NewId()
99
+        {
100
+            // Not sure if properties need it
101
+            return 0;
102
+        }
97 103
     }
98 104
 }

+ 7
- 1
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Bestand weergeven

@@ -439,6 +439,12 @@ namespace UnivateProperties_API.Repository.Properties
439 439
             }
440 440
                 
441 441
             return list;
442
-        }       
442
+        }
443
+
444
+        public int NewId()
445
+        {
446
+            // Not sure if properties need it
447
+            return 0;
448
+        }
443 449
     }
444 450
 }

+ 6
- 0
UnivateProperties_API/Repository/Properties/PropertyTypeRepository.cs Bestand weergeven

@@ -86,5 +86,11 @@ namespace UnivateProperties_API.Repository.Properties
86 86
             dBContext.Entry(item).State = EntityState.Modified;
87 87
             Save();
88 88
         }
89
+
90
+        public int NewId()
91
+        {
92
+            // Not sure if properties need it
93
+            return 0;
94
+        }
89 95
     }
90 96
 }

+ 6
- 0
UnivateProperties_API/Repository/Properties/PropertyUserFieldRepository.cs Bestand weergeven

@@ -86,5 +86,11 @@ namespace UnivateProperties_API.Repository.Properties
86 86
             dBContext.Entry(item).State = EntityState.Modified;
87 87
             Save();
88 88
         }
89
+
90
+        public int NewId()
91
+        {
92
+            // Not sure if properties need it
93
+            return 0;
94
+        }
89 95
     }
90 96
 }

+ 6
- 0
UnivateProperties_API/Repository/Properties/UserDefinedFieldRepository.cs Bestand weergeven

@@ -86,5 +86,11 @@ namespace UnivateProperties_API.Repository.Properties
86 86
             dBContext.Entry(item).State = EntityState.Modified;
87 87
             Save();
88 88
         }
89
+
90
+        public int NewId()
91
+        {
92
+            // Not sure if properties need it
93
+            return 0;
94
+        }
89 95
     }
90 96
 }

+ 6
- 0
UnivateProperties_API/Repository/Properties/UserDefinedGroupRepository.cs Bestand weergeven

@@ -192,5 +192,11 @@ namespace UnivateProperties_API.Repository.Properties
192 192
             dBContext.Entry(item).State = EntityState.Modified;
193 193
             Save();
194 194
         }
195
+
196
+        public int NewId()
197
+        {
198
+            // Not sure if properties need it
199
+            return 0;
200
+        }
195 201
     }
196 202
 }

+ 18
- 3
UnivateProperties_API/Repository/Region/CityRepository.cs Bestand weergeven

@@ -47,17 +47,21 @@ namespace UnivateProperties_API.Repository.Region
47 47
 
48 48
         public void Insert(City item)
49 49
         {
50
-            dBContext.Cities.Add(item);
50
+            item.Id = NewId();
51
+            dBContext.Add(item);
51 52
             Save();
52 53
         }
53 54
 
54 55
         public void Insert(IEnumerable<City> items)
55 56
         {
57
+            int id = NewId();
56 58
             foreach (var item in items)
57 59
             {
58
-                dBContext.Cities.Add(item);
59
-                Save();
60
+                item.Id = id;
61
+                dBContext.Add(item);
62
+                id += 1;
60 63
             }
64
+            Save();
61 65
         }
62 66
 
63 67
         public void Remove(City item)
@@ -95,5 +99,16 @@ namespace UnivateProperties_API.Repository.Region
95 99
             dBContext.Entry(item).State = EntityState.Modified;
96 100
             Save();
97 101
         }
102
+
103
+        public int NewId()
104
+        {
105
+            int id = 0;
106
+            if (dBContext.Cities.Count() > 0)
107
+            {
108
+                id = dBContext.Cities.Max(x => x.Id);
109
+            }
110
+            id += 1;
111
+            return id;
112
+        }
98 113
     }
99 114
 }

+ 18
- 3
UnivateProperties_API/Repository/Region/ProvinceRepository.cs Bestand weergeven

@@ -39,17 +39,21 @@ namespace UnivateProperties_API.Repository.Region
39 39
 
40 40
         public void Insert(Province item)
41 41
         {
42
-            dBContext.Provinces.Add(item);
42
+            item.Id = NewId();
43
+            dBContext.Add(item);
43 44
             Save();
44 45
         }
45 46
 
46 47
         public void Insert(IEnumerable<Province> items)
47 48
         {
49
+            int id = NewId();
48 50
             foreach (var item in items)
49 51
             {
50
-                dBContext.Provinces.Add(item);
51
-                Save();
52
+                item.Id = id;
53
+                dBContext.Add(item);
54
+                id += 1;
52 55
             }
56
+            Save();
53 57
         }
54 58
 
55 59
         public void Remove(Province item)
@@ -87,5 +91,16 @@ namespace UnivateProperties_API.Repository.Region
87 91
             dBContext.Entry(item).State = EntityState.Modified;
88 92
             Save();
89 93
         }
94
+
95
+        public int NewId()
96
+        {
97
+            int id = 0;
98
+            if (dBContext.Provinces.Count() > 0)
99
+            {
100
+                id = dBContext.Provinces.Max(x => x.Id);
101
+            }
102
+            id += 1;
103
+            return id;
104
+        }
90 105
     }
91 106
 }

+ 18
- 3
UnivateProperties_API/Repository/Region/SuburbRepository.cs Bestand weergeven

@@ -48,17 +48,21 @@ namespace UnivateProperties_API.Repository.Region
48 48
 
49 49
         public void Insert(Suburb item)
50 50
         {
51
-            dBContext.Suburbs.Add(item);
51
+            item.Id = NewId();
52
+            dBContext.Add(item);
52 53
             Save();
53 54
         }
54 55
 
55 56
         public void Insert(IEnumerable<Suburb> items)
56 57
         {
58
+            int id = NewId();
57 59
             foreach (var item in items)
58 60
             {
59
-                dBContext.Suburbs.Add(item);
60
-                Save();
61
+                item.Id = id;
62
+                dBContext.Add(item);
63
+                id += 1;
61 64
             }
65
+            Save();
62 66
         }
63 67
 
64 68
         public void Remove(Suburb item)
@@ -96,5 +100,16 @@ namespace UnivateProperties_API.Repository.Region
96 100
             dBContext.Entry(item).State = EntityState.Modified;
97 101
             Save();
98 102
         }
103
+
104
+        public int NewId()
105
+        {
106
+            int id = 0;
107
+            if (dBContext.Suburbs.Count() > 0)
108
+            {
109
+                id = dBContext.Suburbs.Max(x => x.Id);
110
+            }
111
+            id += 1;
112
+            return id;
113
+        }
99 114
     }
100 115
 }

+ 15
- 0
UnivateProperties_API/Repository/Timeshare/SeasonRepository.cs Bestand weergeven

@@ -39,15 +39,19 @@ namespace UnivateProperties_API.Repository.Timeshare
39 39
 
40 40
         public void Insert(Season item)
41 41
         {
42
+            item.Id = NewId();
42 43
             _dbContext.Add(item);
43 44
             Save();
44 45
         }
45 46
 
46 47
         public void Insert(IEnumerable<Season> items)
47 48
         {
49
+            int id = NewId();
48 50
             foreach (var item in items)
49 51
             {
52
+                item.Id = id;
50 53
                 _dbContext.Add(item);
54
+                id += 1;
51 55
             }
52 56
             Save();
53 57
         }
@@ -86,5 +90,16 @@ namespace UnivateProperties_API.Repository.Timeshare
86 90
             _dbContext.Entry(item).State = EntityState.Modified;
87 91
             Save();
88 92
         }
93
+
94
+        public int NewId()
95
+        {
96
+            int id = 0;
97
+            if (_dbContext.Seasons.Count() > 0)
98
+            {
99
+                id = _dbContext.Seasons.Max(x => x.Id);
100
+            }
101
+            id += 1;
102
+            return id;
103
+        }
89 104
     }
90 105
 }

+ 15
- 0
UnivateProperties_API/Repository/Timeshare/StatusRepository.cs Bestand weergeven

@@ -39,15 +39,19 @@ namespace UnivateProperties_API.Repository.Timeshare
39 39
 
40 40
         public void Insert(Status item)
41 41
         {
42
+            item.Id = NewId();
42 43
             _dbContext.Add(item);
43 44
             Save();
44 45
         }
45 46
 
46 47
         public void Insert(IEnumerable<Status> items)
47 48
         {
49
+            int id = NewId();
48 50
             foreach (var item in items)
49 51
             {
52
+                item.Id = id;
50 53
                 _dbContext.Add(item);
54
+                id += 1;
51 55
             }
52 56
             Save();
53 57
         }
@@ -86,5 +90,16 @@ namespace UnivateProperties_API.Repository.Timeshare
86 90
             _dbContext.Entry(item).State = EntityState.Modified;
87 91
             Save();
88 92
         }
93
+
94
+        public int NewId()
95
+        {
96
+            int id = 0;
97
+            if (_dbContext.Status.Count() > 0)
98
+            {
99
+                id = _dbContext.Status.Max(x => x.Id);
100
+            }
101
+            id += 1;
102
+            return id;
103
+        }
89 104
     }
90 105
 }

+ 17
- 0
UnivateProperties_API/Repository/Timeshare/UnitConfigurationRepository.cs Bestand weergeven

@@ -77,21 +77,27 @@ namespace UnivateProperties_API.Repository.Timeshare
77 77
 
78 78
         public void Insert(UnitConfiguration item)
79 79
         {
80
+            item.Id = NewId();
80 81
             _dbContext.Add(item);
81 82
             Save();
82 83
         }
83 84
 
84 85
         public void InsertType(UnitConfigurationType type)
85 86
         {
87
+            int id = _dbContext.UnitConfigurationTypes.Max(x => x.Id);
88
+            type.Id = id + 1;
86 89
             _dbContext.Add(type);
87 90
             Save();
88 91
         }
89 92
 
90 93
         public void Insert(IEnumerable<UnitConfiguration> items)
91 94
         {
95
+            int id = NewId();
92 96
             foreach (var item in items)
93 97
             {
98
+                item.Id = id;
94 99
                 _dbContext.Add(item);
100
+                id += 1;
95 101
             }
96 102
             Save();
97 103
         }
@@ -137,5 +143,16 @@ namespace UnivateProperties_API.Repository.Timeshare
137 143
             _dbContext.Entry(item).State = EntityState.Modified;
138 144
             Save();
139 145
         }
146
+
147
+        public int NewId()
148
+        {
149
+            int id = 0;
150
+            if (_dbContext.UnitConfigurations.Count() > 0)
151
+            {
152
+                id = _dbContext.UnitConfigurations.Max(x => x.Id);
153
+            }
154
+            id += 1;
155
+            return id;
156
+        }
140 157
     }
141 158
 }

+ 43
- 5
UnivateProperties_API/Repository/Timeshare/WeekRepository.cs Bestand weergeven

@@ -46,6 +46,27 @@ namespace UnivateProperties_API.Repository.Timeshare
46 46
             return list;
47 47
         }
48 48
 
49
+        public List<RegionDto> GetAvailResort()
50
+        {
51
+            List<RegionDto> list = new List<RegionDto>();
52
+            foreach (var item in GetDetailedAll())
53
+            {
54
+                if (item.Region != null)
55
+                {
56
+                    if (!list.Any(x => x.RegionCode == item.Region.Code))
57
+                    {
58
+                        list.Add(new RegionDto(item.Region.Code, item.Region.Description));
59
+                    }
60
+                    foreach (var i in list.Where(x => x.RegionCode == item.Region.Code))
61
+                    {
62
+                        i.TryAddResort(item.ResortCode, item.ResortName);
63
+                    }
64
+                }
65
+
66
+            }
67
+            return list;
68
+        }
69
+
49 70
         public List<TimeshareWeek> GetDetailedAll()
50 71
         {
51 72
             var list = GetAll();
@@ -74,6 +95,11 @@ namespace UnivateProperties_API.Repository.Timeshare
74 95
                 StatusRepository status = new StatusRepository(_dbContext);
75 96
                 week.Status = status.Get(x => x.Id == week.StatusId).FirstOrDefault();
76 97
             }
98
+            else
99
+            {
100
+                StatusRepository repo = new StatusRepository(_dbContext);
101
+                week.Status = repo.GetDetailed(s => s.Code == "A1");
102
+            }
77 103
             if (week.RegionId != 0)
78 104
             {
79 105
                 ProvinceRepository province = new ProvinceRepository(_dbContext);
@@ -90,10 +116,7 @@ namespace UnivateProperties_API.Repository.Timeshare
90 116
         public void Insert(TimeshareWeek item)
91 117
         {
92 118
             item = GetDetailedWeek(item);
93
-            // Set starting Status of A1
94
-            StatusRepository repo = new StatusRepository(_dbContext);
95
-            item.Status = repo.GetDetailed(s => s.Code == "A1");
96
-            if(item.Status != null)
119
+            if(item.Status == null)
97 120
             {
98 121
                 //Create initial
99 122
                 item.Status = new Status()
@@ -103,16 +126,20 @@ namespace UnivateProperties_API.Repository.Timeshare
103 126
                     StatusType = StatusType.Timeshare,
104 127
                     ModifiedBy = "KobusB"
105 128
                 };
106
-            }            
129
+            }
130
+            item.Id = NewId();
107 131
             _dbContext.Add(item);
108 132
             Save();
109 133
         }
110 134
 
111 135
         public void Insert(IEnumerable<TimeshareWeek> items)
112 136
         {
137
+            int id = NewId();
113 138
             foreach (var item in items)
114 139
             {
140
+                item.Id = id;
115 141
                 _dbContext.Add(item);
142
+                id += 1;
116 143
             }
117 144
             Save();
118 145
         }
@@ -179,5 +206,16 @@ namespace UnivateProperties_API.Repository.Timeshare
179 206
             }
180 207
             return item;
181 208
         }
209
+
210
+        public int NewId()
211
+        {
212
+            int id = 0;
213
+            if (_dbContext.Weeks.Count() > 0)
214
+            {
215
+                id = _dbContext.Weeks.Max(x => x.Id);
216
+            }
217
+            id += 1;
218
+            return id;
219
+        }
182 220
     }
183 221
 }

+ 19
- 8
UnivateProperties_API/Repository/Users/AgencyRepository.cs Bestand weergeven

@@ -2,7 +2,6 @@
2 2
 using System;
3 3
 using System.Collections.Generic;
4 4
 using System.Linq;
5
-using System.Threading.Tasks;
6 5
 using UnivateProperties_API.Context;
7 6
 using UnivateProperties_API.Model.Users;
8 7
 
@@ -35,21 +34,22 @@ namespace UnivateProperties_API.Repository.Users
35 34
             return item;
36 35
         }
37 36
 
38
-        private Agency GetDetailedObject(Agency item, AgencyRepository repo)
39
-        {
40
-            item = repo.GetDetailed(x => x.Id == item.Id);
41
-            return item;
42
-        }
43
-
44 37
         public void Insert(Agency item)
45 38
         {
39
+            item.Id = NewId();
46 40
             _dbContext.Add(item);
47 41
             Save();
48 42
         }
49 43
 
50 44
         public void Insert(IEnumerable<Agency> item)
51 45
         {
52
-            _dbContext.Add(item);
46
+            int id = NewId();
47
+            foreach (var i in item)
48
+            {
49
+                i.Id = id;
50
+                _dbContext.Add(i);
51
+                id += 1;
52
+            }
53 53
             Save();
54 54
         }
55 55
 
@@ -93,5 +93,16 @@ namespace UnivateProperties_API.Repository.Users
93 93
             //TODO: GetDetailed Agency
94 94
             throw new NotImplementedException();
95 95
         }
96
+
97
+        public int NewId()
98
+        {
99
+            int id = 0;
100
+            if (_dbContext.Agencies.Count() > 0)
101
+            {
102
+                id = _dbContext.Agencies.Max(x => x.Id);
103
+            }
104
+            id += 1;
105
+            return id;
106
+        }
96 107
     }
97 108
 }

+ 16
- 8
UnivateProperties_API/Repository/Users/AgentRepository.cs Bestand weergeven

@@ -3,7 +3,6 @@ using System;
3 3
 using System.Collections.Generic;
4 4
 using System.Linq;
5 5
 using UnivateProperties_API.Context;
6
-using UnivateProperties_API.Helpers;
7 6
 using UnivateProperties_API.Model.Users;
8 7
 
9 8
 namespace UnivateProperties_API.Repository.Users
@@ -36,23 +35,21 @@ namespace UnivateProperties_API.Repository.Users
36 35
             return item;
37 36
         }
38 37
 
39
-        private Agent GetDetailedObject(Agent item, AgentRepository repo)
40
-        {
41
-            item = repo.GetDetailed(x => x.Id == item.Id);
42
-            return item;
43
-        }
44
-
45 38
         public void Insert(Agent item)
46 39
         {
40
+            item.Id = NewId();
47 41
             _dbContext.Add(item);
48 42
             Save();
49 43
         }
50 44
 
51 45
         public void Insert(IEnumerable<Agent> item)
52 46
         {
47
+            int id = NewId();
53 48
             foreach (var i in item)
54 49
             {
55
-                _dbContext.Add(item);
50
+                i.Id = id;
51
+                _dbContext.Add(i);
52
+                id += 1;
56 53
             }
57 54
             Save();
58 55
         }
@@ -97,5 +94,16 @@ namespace UnivateProperties_API.Repository.Users
97 94
             // TODO: GetDetailed
98 95
             throw new NotImplementedException();
99 96
         }
97
+
98
+        public int NewId()
99
+        {
100
+            int id = 0;
101
+            if (_dbContext.Agents.Count() > 0)
102
+            {
103
+                id = _dbContext.Agents.Max(x => x.Id);
104
+            }
105
+            id += 1;
106
+            return id;
107
+        }
100 108
     }
101 109
 }

+ 19
- 1
UnivateProperties_API/Repository/Users/IndividualRepository.cs Bestand weergeven

@@ -42,13 +42,20 @@ namespace UnivateProperties_API.Repository.Users
42 42
 
43 43
         public void Insert(Individual item)
44 44
         {
45
+            item.Id = NewId();
45 46
             _dbContext.Add(item);
46 47
             Save();
47 48
         }
48 49
 
49 50
         public void Insert(IEnumerable<Individual> item)
50 51
         {
51
-            _dbContext.Add(item);
52
+            int id = NewId();
53
+            foreach (var i in item)
54
+            {
55
+                i.Id = id;
56
+                _dbContext.Add(i);
57
+                id += 1;
58
+            }
52 59
             Save();
53 60
         }
54 61
 
@@ -93,5 +100,16 @@ namespace UnivateProperties_API.Repository.Users
93 100
             // TODO: GetDetailed
94 101
             throw new NotImplementedException();
95 102
         }
103
+
104
+        public int NewId()
105
+        {
106
+            int id = 0;
107
+            if (_dbContext.Individuals.Count() > 0)
108
+            {
109
+                id = _dbContext.Individuals.Max(x => x.Id);
110
+            }
111
+            id += 1;
112
+            return id;
113
+        }
96 114
     }
97 115
 }

+ 52
- 36
UnivateProperties_API/Repository/Users/RegisterRepository.cs Bestand weergeven

@@ -1,14 +1,6 @@
1 1
 using Microsoft.AspNetCore.Authorization;
2
-using Microsoft.EntityFrameworkCore;
3
-using Microsoft.Extensions.Options;
4
-using Microsoft.IdentityModel.Tokens;
5
-using System;
6 2
 using System.Collections.Generic;
7
-using System.IdentityModel.Tokens.Jwt;
8 3
 using System.Linq;
9
-using System.Security.Claims;
10
-using System.Text;
11
-using UnivateProperties_API.Containers;
12 4
 using UnivateProperties_API.Containers.Users;
13 5
 using UnivateProperties_API.Context;
14 6
 using UnivateProperties_API.Helpers;
@@ -20,12 +12,9 @@ namespace UnivateProperties_API.Repository.Users
20 12
     {
21 13
         private readonly DataContext _dbContext;
22 14
 
23
-        private readonly AppSettings _appSettings;
24
-
25
-        public RegisterRepository(DataContext dbContext, IOptions<AppSettings> appSettings)
15
+        public RegisterRepository(DataContext dbContext)
26 16
         {
27 17
             _dbContext = dbContext;
28
-            _appSettings = appSettings.Value;
29 18
         }
30 19
 
31 20
         public User Authenticate(string username, string password)
@@ -56,12 +45,11 @@ namespace UnivateProperties_API.Repository.Users
56 45
             if (_dbContext.Users.Any(x => x.Username == user.Username))
57 46
                 throw new AppException("Username \"" + user.Username + "\" is already taken");
58 47
 
59
-            byte[] passwordHash, passwordSalt;
60
-            MyCommon.CreatePasswordHash(password, out passwordHash, out passwordSalt);
48
+            MyCommon.CreatePasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt);
61 49
 
62 50
             user.PasswordHash = passwordHash;
63 51
             user.PasswordSalt = passwordSalt;
64
-
52
+            user.Id = NewUserId();
65 53
             _dbContext.Users.Add(user);
66 54
             if (save)
67 55
             {
@@ -86,7 +74,7 @@ namespace UnivateProperties_API.Repository.Users
86 74
                 EAABEFFCNumber = agency.EaabeffcNumber,
87 75
                 CompanyRegNumber = agency.RegNo
88 76
             };
89
-
77
+            a.Id = NewAgencyId();
90 78
             _dbContext.Agencies.Add(a);
91 79
             CreatePerson(agency.User, PersonType.Agent, false, a);
92 80
 
@@ -103,9 +91,8 @@ namespace UnivateProperties_API.Repository.Users
103 91
 
104 92
             if (_dbContext.Users.Any(x => x.Username == individual.Username))
105 93
                 throw new AppException("Individual \"" + individual.Username + "\" is already taken");
106
-            byte[] passwordHash, passwordSalt;
107 94
 
108
-            MyCommon.CreatePasswordHash(individual.Password, out passwordHash, out passwordSalt);
95
+            MyCommon.CreatePasswordHash(individual.Password, out byte[] passwordHash, out byte[] passwordSalt);
109 96
 
110 97
             User createUser = new User(individual.Username, individual.Password);
111 98
 
@@ -123,6 +110,7 @@ namespace UnivateProperties_API.Repository.Users
123 110
                     Telephone = individual.Telephone,
124 111
                     Agency = agency
125 112
                 };
113
+                agent.Id = NewAgentId();
126 114
                 _dbContext.Agents.Add(agent);
127 115
             }
128 116
             else if (personType == PersonType.Individual)
@@ -136,6 +124,7 @@ namespace UnivateProperties_API.Repository.Users
136 124
                     CellNumber = individual.CellNumber,
137 125
                     Telephone = individual.Telephone
138 126
                 };
127
+                i.Id = NewIndividualId();
139 128
                 _dbContext.Individuals.Add(i);
140 129
             }
141 130
             if (save)
@@ -144,22 +133,6 @@ namespace UnivateProperties_API.Repository.Users
144 133
             }
145 134
         }
146 135
 
147
-        //public void InsertPerson(UserDto item)
148
-        //{
149
-        //    Individual i = new Individual()
150
-        //    {
151
-        //        Name = item.Name,
152
-        //        Surname = item.Surname,
153
-        //        User = new User(item.Username, item.Password),
154
-        //        Email = item.Email,
155
-        //        CellNumber = item.CellNumber,
156
-        //        Telephone = item.Telephone
157
-        //    };
158
-
159
-        //    _dbContext.Add(i);
160
-        //    Save();
161
-        //}
162
-
163 136
         public void Update(User userParam, string password = null)
164 137
         {
165 138
             var user = _dbContext.Users.Find(userParam.Id);
@@ -180,8 +153,7 @@ namespace UnivateProperties_API.Repository.Users
180 153
             // update password if it was entered
181 154
             if (!string.IsNullOrWhiteSpace(password))
182 155
             {
183
-                byte[] passwordHash, passwordSalt;
184
-                MyCommon.CreatePasswordHash(password, out passwordHash, out passwordSalt);
156
+                MyCommon.CreatePasswordHash(password, out byte[] passwordHash, out byte[] passwordSalt);
185 157
 
186 158
                 user.PasswordHash = passwordHash;
187 159
                 user.PasswordSalt = passwordSalt;
@@ -258,5 +230,49 @@ namespace UnivateProperties_API.Repository.Users
258 230
         {
259 231
             _dbContext.SaveChanges();
260 232
         }
233
+
234
+        public int NewAgencyId()
235
+        {
236
+            int id = 0;
237
+            if (_dbContext.Agencies.Count() > 0)
238
+            {
239
+                id = _dbContext.Agencies.Max(x => x.Id);
240
+            }
241
+            id += 1;
242
+            return id;
243
+        }
244
+
245
+        public int NewAgentId()
246
+        {
247
+            int id = 0;
248
+            if (_dbContext.Agents.Count() > 0)
249
+            {
250
+                id = _dbContext.Agents.Max(x => x.Id);
251
+            }
252
+            id += 1;
253
+            return id;
254
+        }
255
+
256
+        public int NewIndividualId()
257
+        {
258
+            int id = 0;
259
+            if (_dbContext.Individuals.Count() > 0)
260
+            {
261
+                id = _dbContext.Individuals.Max(x => x.Id);
262
+            }
263
+            id += 1;
264
+            return id;
265
+        }
266
+
267
+        public int NewUserId()
268
+        {
269
+            int id = 0;
270
+            if (_dbContext.Users.Count() > 0)
271
+            {
272
+                id = _dbContext.Users.Max(x => x.Id);
273
+            }
274
+            id += 1;
275
+            return id;
276
+        }
261 277
     }
262 278
 }

+ 21
- 16
UnivateProperties_API/Repository/Users/UserRepository.cs Bestand weergeven

@@ -1,12 +1,6 @@
1
-using Microsoft.EntityFrameworkCore;
2
-using Microsoft.Extensions.Options;
3
-using Microsoft.IdentityModel.Tokens;
4
-using System;
1
+using System;
5 2
 using System.Collections.Generic;
6
-using System.IdentityModel.Tokens.Jwt;
7 3
 using System.Linq;
8
-using System.Security.Claims;
9
-using System.Text;
10 4
 using UnivateProperties_API.Context;
11 5
 using UnivateProperties_API.Helpers;
12 6
 using UnivateProperties_API.Model.Users;
@@ -48,13 +42,20 @@ namespace UnivateProperties_API.Repository.Users
48 42
 
49 43
         public void Insert(User item)
50 44
         {
45
+            item.Id = NewId();
51 46
             _dbContext.Add(item);
52 47
             Save();
53 48
         }
54 49
 
55 50
         public void Insert(IEnumerable<User> item)
56 51
         {
57
-            _dbContext.Add(item);
52
+            int id = NewId();
53
+            foreach (var i in item)
54
+            {
55
+                i.Id = id;
56
+                _dbContext.Add(i);
57
+                id += 1;
58
+            }
58 59
             Save();
59 60
         }
60 61
 
@@ -82,12 +83,6 @@ namespace UnivateProperties_API.Repository.Users
82 83
             Save();
83 84
         }
84 85
 
85
-        //public void Update(User item)
86
-        //{
87
-        //    _dbContext.Entry(item).State = EntityState.Modified;
88
-        //    Save();
89
-        //}
90
-
91 86
         public void Update(User userParam)
92 87
         {
93 88
             var user = _dbContext.Users.Find(userParam.Id);
@@ -108,8 +103,7 @@ namespace UnivateProperties_API.Repository.Users
108 103
             // update password if it was entered
109 104
             if (!string.IsNullOrWhiteSpace(userParam.PasswordHash.ToString()))
110 105
             {
111
-                byte[] passwordHash, passwordSalt;
112
-                CreatePasswordHash(userParam.PasswordHash.ToString(), out passwordHash, out passwordSalt);
106
+                CreatePasswordHash(userParam.PasswordHash.ToString(), out byte[] passwordHash, out byte[] passwordSalt);
113 107
 
114 108
                 user.PasswordHash = passwordHash;
115 109
                 user.PasswordSalt = passwordSalt;
@@ -140,5 +134,16 @@ namespace UnivateProperties_API.Repository.Users
140 134
         {
141 135
             throw new NotImplementedException();
142 136
         }
137
+
138
+        public int NewId()
139
+        {
140
+            int id = 0;
141
+            if (_dbContext.Users.Count() > 0)
142
+            {
143
+                id = _dbContext.Users.Max(x => x.Id);
144
+            }
145
+            id += 1;
146
+            return id;
147
+        }
143 148
     }
144 149
 }

+ 1
- 1
UnivateProperties_API/appsettings.json Bestand weergeven

@@ -9,6 +9,6 @@
9 9
   },
10 10
   "AllowedHosts": "*",
11 11
   "ConnectionStrings": {
12
-    "DefaultConnection": "Server=localhost;Port=5432;Database=Univate;User Id=postgres;Password=Prov1s1on;"
12
+    "DefaultConnection": "Server=localhost;Port=5432;Database=Univate;User Id=postgres;Password=prov1s1on;"
13 13
   }
14 14
 }

Laden…
Annuleren
Opslaan