Browse Source

Error on saving property fix

master
GJWilliams87 4 years ago
parent
commit
c567caabcb

+ 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;

Loading…
Cancel
Save