Просмотр исходного кода

Error on saving property fix

master
GJWilliams87 4 лет назад
Родитель
Сommit
c567caabcb
1 измененных файлов: 6 добавлений и 1 удалений
  1. 6
    1
      UnivateProperties_API/Repository/Properties/PropertyRepository.cs

+ 6
- 1
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Просмотреть файл

@@ -848,7 +848,12 @@ namespace UnivateProperties_API.Repository.Properties
848 848
                 }
849 849
 
850 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 857
                 foreach (PropertyImage image in images)
853 858
                 {
854 859
                     image.PropertyId = property.Id;

Загрузка…
Отмена
Сохранить