Browse Source

Removed Id creation on registering as SQL handles it now

master
Lene 4 years ago
parent
commit
b0128bdaf1

+ 1
- 1
UnivateProperties_API/Repository/IRepository.cs View File

16
         void Remove(IEnumerable<TEntity> items);
16
         void Remove(IEnumerable<TEntity> items);
17
         void RemoveAtId(int item);
17
         void RemoveAtId(int item);
18
         void Update(TEntity item);
18
         void Update(TEntity item);
19
-        int NewId();
19
+        //int NewId();
20
         void Save();
20
         void Save();
21
     }
21
     }
22
 }
22
 }

+ 47
- 47
UnivateProperties_API/Repository/Users/RegisterRepository.cs View File

52
 
52
 
53
             user.PasswordHash = passwordHash;
53
             user.PasswordHash = passwordHash;
54
             user.PasswordSalt = passwordSalt;
54
             user.PasswordSalt = passwordSalt;
55
-            user.Id = NewUserId();
55
+            //user.Id = NewUserId();
56
             _dbContext.Users.Add(user);
56
             _dbContext.Users.Add(user);
57
             if (save)
57
             if (save)
58
             {
58
             {
77
                 EAABEFFCNumber = agency.EaabeffcNumber,
77
                 EAABEFFCNumber = agency.EaabeffcNumber,
78
                 CompanyRegNumber = agency.RegNo
78
                 CompanyRegNumber = agency.RegNo
79
             };
79
             };
80
-            a.Id = NewAgencyId();
80
+            //a.Id = NewAgencyId();
81
             _dbContext.Agencies.Add(a);
81
             _dbContext.Agencies.Add(a);
82
             CreatePerson(agency.User, PersonType.Agent, false, a);
82
             CreatePerson(agency.User, PersonType.Agent, false, a);
83
 
83
 
115
                     Telephone = individual.Telephone,
115
                     Telephone = individual.Telephone,
116
                     Agency = agency
116
                     Agency = agency
117
                 };
117
                 };
118
-                agent.Id = NewAgentId();
118
+                //agent.Id = NewAgentId();
119
                 agent.User.Role = Role.Agency;
119
                 agent.User.Role = Role.Agency;
120
                 p = agent;
120
                 p = agent;
121
                 _dbContext.Agents.Add(agent);
121
                 _dbContext.Agents.Add(agent);
131
                     CellNumber = individual.CellNumber,
131
                     CellNumber = individual.CellNumber,
132
                     Telephone = individual.Telephone
132
                     Telephone = individual.Telephone
133
                 };
133
                 };
134
-                i.Id = NewIndividualId();
134
+                //i.Id = NewIndividualId();
135
                 i.User.Role = Role.PrivateUser;
135
                 i.User.Role = Role.PrivateUser;
136
                 p = i;
136
                 p = i;
137
                 _dbContext.Individuals.Add(i);
137
                 _dbContext.Individuals.Add(i);
262
             _dbContext.SaveChanges();
262
             _dbContext.SaveChanges();
263
         }
263
         }
264
 
264
 
265
-        public int NewAgencyId()
266
-        {
267
-            int id = 0;
268
-            if (_dbContext.Agencies.Count() > 0)
269
-            {
270
-                id = _dbContext.Agencies.Max(x => x.Id);
271
-            }
272
-            id += 1;
273
-            return id;
274
-        }
275
-
276
-        public int NewAgentId()
277
-        {
278
-            int id = 0;
279
-            if (_dbContext.Agents.Count() > 0)
280
-            {
281
-                id = _dbContext.Agents.Max(x => x.Id);
282
-            }
283
-            id += 1;
284
-            return id;
285
-        }
286
-
287
-        public int NewIndividualId()
288
-        {
289
-            int id = 0;
290
-            if (_dbContext.Individuals.Count() > 0)
291
-            {
292
-                id = _dbContext.Individuals.Max(x => x.Id);
293
-            }
294
-            id += 1;
295
-            return id;
296
-        }
297
-
298
-        public int NewUserId()
299
-        {
300
-            int id = 0;
301
-            if (_dbContext.Users.Count() > 0)
302
-            {
303
-                id = _dbContext.Users.Max(x => x.Id);
304
-            }
305
-            id += 1;
306
-            return id;
307
-        }
265
+        //public int NewAgencyId()
266
+        //{
267
+        //    int id = 0;
268
+        //    if (_dbContext.Agencies.Count() > 0)
269
+        //    {
270
+        //        id = _dbContext.Agencies.Max(x => x.Id);
271
+        //    }
272
+        //    id += 1;
273
+        //    return id;
274
+        //}
275
+
276
+        //public int NewAgentId()
277
+        //{
278
+        //    int id = 0;
279
+        //    if (_dbContext.Agents.Count() > 0)
280
+        //    {
281
+        //        id = _dbContext.Agents.Max(x => x.Id);
282
+        //    }
283
+        //    id += 1;
284
+        //    return id;
285
+        //}
286
+
287
+        //public int NewIndividualId()
288
+        //{
289
+        //    int id = 0;
290
+        //    if (_dbContext.Individuals.Count() > 0)
291
+        //    {
292
+        //        id = _dbContext.Individuals.Max(x => x.Id);
293
+        //    }
294
+        //    id += 1;
295
+        //    return id;
296
+        //}
297
+
298
+        //public int NewUserId()
299
+        //{
300
+        //    int id = 0;
301
+        //    if (_dbContext.Users.Count() > 0)
302
+        //    {
303
+        //        id = _dbContext.Users.Max(x => x.Id);
304
+        //    }
305
+        //    id += 1;
306
+        //    return id;
307
+        //}
308
 
308
 
309
         public SimplePersonDto UserDetails(int userId)
309
         public SimplePersonDto UserDetails(int userId)
310
         {
310
         {

+ 18
- 18
UnivateProperties_API/Repository/Users/UserRepository.cs View File

42
 
42
 
43
         public void Insert(User item)
43
         public void Insert(User item)
44
         {
44
         {
45
-            item.Id = NewId();
45
+            //item.Id = NewId();
46
             _dbContext.Add(item);
46
             _dbContext.Add(item);
47
             Save();
47
             Save();
48
         }
48
         }
49
 
49
 
50
         public void Insert(IEnumerable<User> item)
50
         public void Insert(IEnumerable<User> item)
51
         {
51
         {
52
-            int id = NewId();
53
-            foreach (var i in item)
54
-            {
55
-                i.Id = id;
56
-                _dbContext.Add(i);
57
-                id += 1;
58
-            }
52
+            //int id = NewId();
53
+            //foreach (var i in item)
54
+            //{
55
+            //    i.Id = id;
56
+                _dbContext.Add(item);
57
+            //    id += 1;
58
+            //}
59
             Save();
59
             Save();
60
         }
60
         }
61
 
61
 
135
             throw new NotImplementedException();
135
             throw new NotImplementedException();
136
         }
136
         }
137
 
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
-        }
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
+        //}
148
     }
148
     }
149
 }
149
 }

+ 1
- 1
UnivateProperties_API/appsettings.json View File

9
   },
9
   },
10
   "AllowedHosts": "*",
10
   "AllowedHosts": "*",
11
   "ConnectionStrings": {
11
   "ConnectionStrings": {
12
-    "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
12
+    "DefaultConnection": "Data Source=192.168.0.219;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
13
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail_test.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N"
13
     "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail_test.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N"
14
   }
14
   }
15
 }
15
 }

Loading…
Cancel
Save