public async Task CreateOrUpdateArticleTagInfo(CreateOrUpdateArticleInfoArticleTagInfoDto input) { if (!input.ArticleTagInfo.Id.HasValue) { await CreateArticleTagInfoAsync(input); } else { await UpdateArticleTagInfoAsync(input); } }
protected virtual async Task UpdateArticleTagInfoAsync(CreateOrUpdateArticleInfoArticleTagInfoDto input) { Debug.Assert(input.ArticleTagInfo.Id != null, "必须设置input.ArticleTagInfo.Id的值"); var articleTagInfo = await _articleTagInfoRepository.GetAsync(input.ArticleTagInfo.Id.Value); if (input.ArticleTagInfo.Name != articleTagInfo.Name) { if (_articleTagInfoRepository.GetAll().Any(p => p.Name == input.ArticleTagInfo.Name)) { throw new UserFriendlyException(L("NameExist")); } } articleTagInfo.ArticleInfoId = input.ArticleTagInfo.ArticleInfoId; articleTagInfo.Name = input.ArticleTagInfo.Name; }
protected virtual async Task CreateArticleTagInfoAsync(CreateOrUpdateArticleInfoArticleTagInfoDto input) { if (_articleTagInfoRepository.GetAll().Any(p => p.Name == input.ArticleTagInfo.Name)) { throw new UserFriendlyException(L("NameExist")); } var articleTagInfo = new ArticleTagInfo() { ArticleInfoId = input.ArticleTagInfo.ArticleInfoId, Name = input.ArticleTagInfo.Name, CreatorUserId = AbpSession.UserId, CreationTime = Clock.Now, TenantId = AbpSession.TenantId }; await _articleTagInfoRepository.InsertAsync(articleTagInfo); }