|
@@ -171,42 +171,111 @@ namespace GxPress.Repository.Implement.Media
|
|
|
|
|
|
public async Task<bool> UpdateAsync(MediaResult result)
|
|
|
{
|
|
|
- var model = _mapper.Map<Entity.tede2.Media.Media>(result);
|
|
|
+ //var model = _mapper.Map<Entity.tede2.Media.Media>(result);
|
|
|
try
|
|
|
{
|
|
|
using (var transactionScope = new TransactionScope())
|
|
|
{
|
|
|
- var categoryId = "";
|
|
|
- foreach (var item in result.CategoryId)
|
|
|
+ var model = await _repository.GetAsync(result.Id);
|
|
|
+ if (result.CategoryId.Count > 0)
|
|
|
{
|
|
|
- categoryId += item.Split(",")[item.Split(",").Length - 1] + ",";
|
|
|
+ var categoryId = "";
|
|
|
+ foreach (var item in result.CategoryId)
|
|
|
+ categoryId += item.Split(",")[item.Split(",").Length - 1] + ",";
|
|
|
+ categoryId = categoryId.Remove(categoryId.Length - 1, 1);
|
|
|
+ model.CategoryId = categoryId;
|
|
|
+ model.FullCategoryId = StringUtils.ObjectCollectionToString(result.CategoryId);
|
|
|
}
|
|
|
- categoryId = categoryId.Remove(categoryId.Length - 1, 1);
|
|
|
- model.CategoryId = categoryId;
|
|
|
- model.FullCategoryId = StringUtils.ObjectCollectionToString(result.CategoryId);
|
|
|
- var categoryName = "";
|
|
|
- foreach (var item in result.CategoryName)
|
|
|
+ if (result.CategoryName.Count > 0)
|
|
|
{
|
|
|
- categoryName += item.Split(",")[item.Split(",").Length - 1] + ",";
|
|
|
+ var categoryName = "";
|
|
|
+ foreach (var item in result.CategoryName)
|
|
|
+ categoryName += item.Split(",")[item.Split(",").Length - 1] + ",";
|
|
|
+ categoryName = categoryName.Remove(categoryName.Length - 1, 1);
|
|
|
+ model.CategoryName = categoryName;
|
|
|
}
|
|
|
- categoryName = categoryName.Remove(categoryName.Length - 1, 1);
|
|
|
- model.CategoryName = categoryName;
|
|
|
- model.IsLibrary = result.MediaLibraryResults.Count > 0;
|
|
|
+ if (result.AdminId > 0)
|
|
|
+ model.AdminId = result.AdminId;
|
|
|
+ if (!string.IsNullOrEmpty(result.Creator))
|
|
|
+ model.Creator = result.Creator;
|
|
|
+ if (result.MediaType > 0)
|
|
|
+ model.MediaType = result.MediaType;
|
|
|
+ if (!string.IsNullOrEmpty(result.Title))
|
|
|
+ model.Title = result.Title;
|
|
|
+ if (!string.IsNullOrEmpty(result.ImageUrls))
|
|
|
+ model.ImageUrls = result.ImageUrls;
|
|
|
+ if (!string.IsNullOrEmpty(result.Summary))
|
|
|
+ model.Summary = result.Summary;
|
|
|
+ if (!string.IsNullOrEmpty(result.Author))
|
|
|
+ model.Author = result.Author;
|
|
|
+ if (result.TeacherId > 0)
|
|
|
+ model.TeacherId = result.TeacherId;
|
|
|
+ if (!string.IsNullOrEmpty(result.Source))
|
|
|
+ model.Source = result.Source;
|
|
|
+ if (!string.IsNullOrEmpty(result.Blocks))
|
|
|
+ model.Blocks = result.Blocks;
|
|
|
+ if (result.IsChecked > 0)
|
|
|
+ model.IsChecked = result.IsChecked == 1;
|
|
|
+ if (!string.IsNullOrEmpty(result.AddDate))
|
|
|
+ model.AddDate = Convert.ToDateTime(result.AddDate);
|
|
|
+ if (model.Sort > 0)
|
|
|
+ model.Sort = result.Sort;
|
|
|
+ if (model.ReadCount > 0)
|
|
|
+ model.ReadCount = result.ReadCount;
|
|
|
+ if (result.IsTop > 0)
|
|
|
+ model.IsTop = result.IsTop == 1;
|
|
|
+ if (result.LableId > 0)
|
|
|
+ model.LableId = result.LableId;
|
|
|
+ if (result.IsRecommend > 0)
|
|
|
+ model.IsRecommend = result.IsRecommend == 1;
|
|
|
+ if (!string.IsNullOrEmpty(result.Press))
|
|
|
+ model.Press = result.Press;
|
|
|
+ if (!string.IsNullOrEmpty(result.PublishTime))
|
|
|
+ model.PublishTime = result.PublishTime;
|
|
|
+ if (result.IosDiscountPrice > 0)
|
|
|
+ model.IosDiscountPrice = result.IosDiscountPrice;
|
|
|
+ if (result.IosPrice > 0)
|
|
|
+ model.IosPrice = result.IosPrice;
|
|
|
+ if (result.OtherDiscountPrice > 0)
|
|
|
+ model.OtherDiscountPrice = result.OtherDiscountPrice;
|
|
|
+ if (result.OtherPrice > 0)
|
|
|
+ model.OtherPrice = result.OtherPrice;
|
|
|
+ if (result.FreeProportion > 0)
|
|
|
+ model.FreeProportion = result.FreeProportion;
|
|
|
+ if (result.AttachType > 0)
|
|
|
+ model.AttachType = result.AttachType;
|
|
|
+ if (result.AttachId > 0)
|
|
|
+ model.AttachId = result.AttachId;
|
|
|
+ if (result.MediaId > 0)
|
|
|
+ model.MediaId = result.MediaId;
|
|
|
+ if (!string.IsNullOrEmpty(result.MediaTitle))
|
|
|
+ model.MediaTitle = result.MediaTitle;
|
|
|
+ if (!string.IsNullOrEmpty(result.JournalsYear))
|
|
|
+ model.JournalsYear = result.JournalsYear;
|
|
|
+ if (result.JournalsCategory > 0)
|
|
|
+ model.JournalsCategory = result.JournalsCategory;
|
|
|
await _repository.UpdateAsync(model);
|
|
|
- //删除媒体库
|
|
|
- await mediaLibraryRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLibrary.MediaId), result.Id));
|
|
|
- //删除媒体标签
|
|
|
- await mediaLableRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), result.Id));
|
|
|
- foreach (var item in result.MediaLibraryResults)
|
|
|
+ if (result.MediaLibraryResults.Count > 0)
|
|
|
{
|
|
|
- var mediaLibrary = _mapper.Map<Entity.tede2.Media.MediaLibrary>(item);
|
|
|
- await mediaLibraryRepository.InsertAsync(mediaLibrary);
|
|
|
+ model.IsLibrary = result.MediaLibraryResults.Count > 0;
|
|
|
+ //删除媒体库
|
|
|
+ await mediaLibraryRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLibrary.MediaId), result.Id));
|
|
|
+ foreach (var item in result.MediaLibraryResults)
|
|
|
+ {
|
|
|
+ var mediaLibrary = _mapper.Map<Entity.tede2.Media.MediaLibrary>(item);
|
|
|
+ await mediaLibraryRepository.InsertAsync(mediaLibrary);
|
|
|
+ }
|
|
|
}
|
|
|
- //添加标签
|
|
|
- foreach (var item in result.MediaLableResults)
|
|
|
+ if (result.MediaLableResults.Count > 0)
|
|
|
{
|
|
|
- var mediaLable = _mapper.Map<Entity.tede2.Media.MediaLable>(item);
|
|
|
- await mediaLableRepository.InsertAsync(mediaLable);
|
|
|
+ //删除媒体标签
|
|
|
+ await mediaLableRepository.DeleteAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.MediaId), result.Id));
|
|
|
+ //添加标签
|
|
|
+ foreach (var item in result.MediaLableResults)
|
|
|
+ {
|
|
|
+ var mediaLable = _mapper.Map<Entity.tede2.Media.MediaLable>(item);
|
|
|
+ await mediaLableRepository.InsertAsync(mediaLable);
|
|
|
+ }
|
|
|
}
|
|
|
//提交事务
|
|
|
transactionScope.Complete();
|