Example #1
0
        public static Comment CreateOrLoadComment(
            CommentModel comment,
            IRepository <Comment> commentRepository,
            DbUsersRepository usersRepository)
        {
            Comment commentEntity = commentRepository.Get(comment.ID);

            if (commentEntity != null)
            {
                return(commentEntity);
            }

            Comment newComment = CommentsMapper.ToCommentEntity(comment, usersRepository);

            return(newComment);
        }
Example #2
0
        public static NewsArticleModel ToNewsArticleModel(NewsArticle newsArticle)
        {
            NewsArticleModel newsArticleModel = new NewsArticleModel()
            {
                ID      = newsArticle.ID,
                Title   = newsArticle.Title,
                Content = newsArticle.Content,
                Rating  = newsArticle.Rating,
                Date    = newsArticle.Date,
                Author  = newsArticle.Author.Nickname
            };

            foreach (Comment comment in newsArticle.Comments)
            {
                newsArticleModel.Comments.Add(CommentsMapper.ToCommentModel(comment));
            }

            return(newsArticleModel);
        }