Exemplo n.º 1
0
 public async Task CreateOrUpdateArticleSourceInfo(CreateOrUpdateArticleSourceInfoDto input)
 {
     if (!input.ArticleSourceInfo.Id.HasValue)
     {
         await CreateArticleSourceInfoAsync(input);
     }
     else
     {
         await UpdateArticleSourceInfoAsync(input);
     }
 }
Exemplo n.º 2
0
        protected virtual async Task UpdateArticleSourceInfoAsync(CreateOrUpdateArticleSourceInfoDto input)
        {
            Debug.Assert(input.ArticleSourceInfo.Id != null, "必须设置input.ArticleSourceInfo.Id的值");

            var articleSourceInfo = await _articleSourceInfoRepository.GetAsync(input.ArticleSourceInfo.Id.Value);

            if (input.ArticleSourceInfo.Name != articleSourceInfo.Name)
            {
                if (_articleSourceInfoRepository.GetAll().Any(p => p.Name == input.ArticleSourceInfo.Name))
                {
                    throw new UserFriendlyException(L("NameExist"));
                }
            }
            articleSourceInfo.Name = input.ArticleSourceInfo.Name;
        }
Exemplo n.º 3
0
 protected virtual async Task CreateArticleSourceInfoAsync(CreateOrUpdateArticleSourceInfoDto input)
 {
     if (_articleSourceInfoRepository.GetAll().Any(p => p.Name == input.ArticleSourceInfo.Name))
     {
         throw new UserFriendlyException(L("NameExist"));
     }
     var articleSourceInfo = new ArticleSourceInfo()
     {
         Name          = input.ArticleSourceInfo.Name,
         CreatorUserId = AbpSession.UserId,
         CreationTime  = Clock.Now,
         TenantId      = AbpSession.TenantId
     };
     await _articleSourceInfoRepository.InsertAsync(articleSourceInfo);
 }