public void Handle(UpdateArticleTagCommand command) { var articleTag = _articleTagRepository.Load(command.ArticleTagId); Guard.IsNotNull(articleTag, "articleTag"); if (articleTag.User.Id != command.CurrentUserId) { throw new BusinessException("非法操作"); return; } var isHaveArticleTag = (from query in _articleTagRepository.FindAll() where query.TagName == command.TagName && query.Id != articleTag.Id select query); if (isHaveArticleTag.Count() > 0) { throw new BusinessException("已经存在相同的文章标签名称!"); } if (command.IsShow != null) { articleTag.IsShow = (bool)command.IsShow; } if (!string.IsNullOrEmpty(command.TagName)) { articleTag.TagName = command.TagName.Trim(); } articleTag.LastDateTime = DateTime.Now; _articleTagRepository.SaveOrUpdate(articleTag); }
public void Handle(DeleteArticleTagCommand command) { var articleTag = _articleTagRepository.Load(command.ArticleTagId); Guard.IsNotNull(articleTag, "articleType"); _articleTagRepository.Delete(articleTag); }