コード例 #1
0
ファイル: ArticleService.cs プロジェクト: sergeu90/OurMemory
        public Comment AddComment(int id, string message, string userId)
        {
            _articleRepository.DetachAllEntities();

            var article = _articleRepository.GetById(id);

            var user = userId == null ? null : _userService.GetById(userId);

            var comment = new Comment()
            {
                Article = article,
                User = user,
                Message = message,
                UpdatedDateTime = DateTime.UtcNow
            };

            article.Comments.Add(comment);

            UpdateArticle(article);

            return comment;
        }
コード例 #2
0
ファイル: CommentService.cs プロジェクト: sergeu90/OurMemory
 public void UpdateComment(Comment comment)
 {
     _commentRepository.Update(comment);
     SaveComment();
 }