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; }
public void UpdateComment(Comment comment) { _commentRepository.Update(comment); SaveComment(); }