public void Handle(DeleteArticleMessageCommand command) { var articleMessage = _articleMessageRepository.Get(command.ArticleMessageId); Guard.IsNotNull(articleMessage, "articleMessage"); if (articleMessage.Article.User.Id != command.UserId) { throw new BusinessException("不允许删除其他用户的留言信息"); } var part = new Dictionary <string, object> { { "@ArticleMessageID", command.ArticleMessageId } }; _articleMessageRepository.ExecuteProcedure("Cotide_DeleteArticleMessage", part); }
public void GetTest() { var domain = _articleMessageRepository.Get(1048); //var list = domain.ArticleReplyMessages; //Console.WriteLine(list.Count); }
public void Handle(CreateArticleMessageReplyCommand command) { var articleMessage = ArticleMessageRepository.Get(command.ArticleMessageId); Guard.IsNotNull(articleMessage, "articleMessage"); if (command.UserId != null) { // 用户留言回复 var user = UserRepository.Get((int)command.UserId); Guard.IsNotNull(user, "user"); //// 用户留言 //var reply = new ArticleReplyMessage() //{ // Content = HttpUtility.HtmlEncode(command.Content), // CreateDate = DateTime.Now, // IsShow = command.IsShow, // User = user // //ArticleMessage = articleMessage //}; // 用户留言 var reply = new ArticleMessage() { Content = HttpUtility.HtmlEncode(command.Content), CreateDate = DateTime.Now, IsShow = command.IsShow, User = user, Article = articleMessage.Article, BaseArticleMessage = articleMessage, LastDateTime = DateTime.Now }; // articleMessage.AddArticleMessage(reply); //if(command.BaseArticleReplyMessageId!=null) //{ // var baseArticleReplyMessage = // ArticleReplyMessageRepository.Get(int.Parse(command.BaseArticleReplyMessageId.ToString())); // Guard.IsNotNull(baseArticleReplyMessage, "baseArticleReplyMessage"); // reply.BaseArticleReplyMessage = baseArticleReplyMessage; //} // articleMessage.ArticleReplyMessages.Add(reply); ArticleMessageRepository.Save(reply); } else { var reply = new ArticleMessage() { NickName = command.NickName, Email = command.Email, WebSiteUrl = command.WebSiteUrl, Content = HttpUtility.HtmlEncode(command.Content), CreateDate = DateTime.Now, IsShow = command.IsShow, BaseArticleMessage = articleMessage, Article = articleMessage.Article, LastDateTime = DateTime.Now }; // articleMessage.AddArticleReplyMessage(reply); ArticleMessageRepository.Save(reply); } }