李昊 4 years ago
parent
commit
3f65e7bf17

+ 4 - 4
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -177,7 +177,7 @@ namespace GxPress.Repository.Implement.Media
                 using (var transactionScope = new TransactionScope())
                 {
                     var model = await _repository.GetAsync(result.Id);
-                    if (result.CategoryId.Count > 0)
+                    if (result.CategoryId != null && result.CategoryId.Count > 0)
                     {
                         var categoryId = "";
                         foreach (var item in result.CategoryId)
@@ -186,7 +186,7 @@ namespace GxPress.Repository.Implement.Media
                         model.CategoryId = categoryId;
                         model.FullCategoryId = StringUtils.ObjectCollectionToString(result.CategoryId);
                     }
-                    if (result.CategoryName.Count > 0)
+                    if (result.CategoryName != null && result.CategoryName.Count > 0)
                     {
                         var categoryName = "";
                         foreach (var item in result.CategoryName)
@@ -255,7 +255,7 @@ namespace GxPress.Repository.Implement.Media
                     if (result.JournalsCategory > 0)
                         model.JournalsCategory = result.JournalsCategory;
                     await _repository.UpdateAsync(model);
-                    if (result.MediaLibraryResults.Count > 0)
+                    if (result.MediaLibraryResults != null && result.MediaLibraryResults.Count > 0)
                     {
                         model.IsLibrary = result.MediaLibraryResults.Count > 0;
                         //删除媒体库
@@ -266,7 +266,7 @@ namespace GxPress.Repository.Implement.Media
                             await mediaLibraryRepository.InsertAsync(mediaLibrary);
                         }
                     }
-                    if (result.MediaLableResults.Count > 0)
+                    if (result.MediaLableResults != null && result.MediaLableResults.Count > 0)
                     {
                         //删除媒体标签
                         await mediaLableRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), result.Id));