2 Commits

Author SHA1 Message Date
  GJWilliams87 c567caabcb Error on saving property fix 4 years ago
  GJWilliams87 a5b8e31663 Error handling to fix error in live 4 years ago

+ 1
- 1
UnivateProperties_API/Controllers/Users/RegisterController.cs View File

112
             }
112
             }
113
             catch(Exception ex)
113
             catch(Exception ex)
114
             {
114
             {
115
-                return new BadRequestResult();
115
+                return BadRequest(new { message = ex.Message + " - " + ex.InnerException + " - " + ex.StackTrace });
116
             }
116
             }
117
         }
117
         }
118
 
118
 

+ 6
- 1
UnivateProperties_API/Repository/Properties/PropertyRepository.cs View File

848
                 }
848
                 }
849
 
849
 
850
                 property.PropertyImages = new List<PropertyImage>();
850
                 property.PropertyImages = new List<PropertyImage>();
851
-                var lastID = dBContext.PropertyImages.Max(i => i.Id) + 1;
851
+                var lastID = 0;
852
+                if (dBContext.PropertyImages.Count() == 0)
853
+                    lastID = 1;
854
+                else 
855
+                    lastID = dBContext.PropertyImages.Max(i => i.Id) + 1;
856
+
852
                 foreach (PropertyImage image in images)
857
                 foreach (PropertyImage image in images)
853
                 {
858
                 {
854
                     image.PropertyId = property.Id;
859
                     image.PropertyId = property.Id;

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

1
 using Microsoft.AspNetCore.Authorization;
1
 using Microsoft.AspNetCore.Authorization;
2
 using Microsoft.AspNetCore.Mvc;
2
 using Microsoft.AspNetCore.Mvc;
3
+using Microsoft.EntityFrameworkCore;
3
 using System;
4
 using System;
4
 using System.Collections.Generic;
5
 using System.Collections.Generic;
5
 using System.Drawing.Text;
6
 using System.Drawing.Text;
195
                 user.PasswordSalt = passwordSalt;
196
                 user.PasswordSalt = passwordSalt;
196
             }
197
             }
197
 
198
 
198
-            _dbContext.Users.Update(user);
199
+            //_dbContext.Users.Update(user);
200
+            _dbContext.Entry(user).State = EntityState.Modified;
199
             _dbContext.SaveChanges();
201
             _dbContext.SaveChanges();
200
         }
202
         }
201
 
203
 
273
             user.PasswordSalt = passwordSalt;
275
             user.PasswordSalt = passwordSalt;
274
             user.FPToken = "";
276
             user.FPToken = "";
275
 
277
 
276
-            _dbContext.Users.Update(user);
278
+            //_dbContext.Users.Update(user);
279
+            _dbContext.Entry(user).State = EntityState.Modified;
277
             Save();
280
             Save();
278
         }
281
         }
279
 
282
 
401
                 //send ecrypted token to db
404
                 //send ecrypted token to db
402
                 user.FPToken = encryptedToken;
405
                 user.FPToken = encryptedToken;
403
 
406
 
404
-                _dbContext.Users.Update(user);
407
+                _dbContext.Entry(user).State = EntityState.Modified;
408
+                //_dbContext.Users.Update(user);
405
                 _dbContext.SaveChanges();
409
                 _dbContext.SaveChanges();
406
 
410
 
407
                 string linkStr = encryptedToken.Replace('/', '!');
411
                 string linkStr = encryptedToken.Replace('/', '!');

Loading…
Cancel
Save