Ejemplo n.º 1
0
        public static NewsPostSimplifiedCollection GenerateNewsPostSimplifiedCollection(ToolsModel model)
        {
            var commentService = CommentHelper.CommentService;

            var businessModel = model.ConvertToOptions();
            var newsPosts     = NewsPostService.GetNewsPostsWithTools(businessModel);

            var newsPostSimplifiedViews = new List <NewsPostSimplifiedView>();

            foreach (NewsPost newsPost in newsPosts)
            {
                int commentCount = commentService.GetCommentCountByPostId(newsPost.Id);
                newsPostSimplifiedViews.Add(new NewsPostSimplifiedView(newsPost, commentCount));
            }
            model.Pages = businessModel.Pages;
            return(new NewsPostSimplifiedCollection(newsPostSimplifiedViews, model));
        }
Ejemplo n.º 2
0
        public static NewsPostAdminCollection GenerateNewsPostAdminCollection(ToolsModel model)
        {
            var adminService   = AdminHelper.AdminService;
            var commentService = CommentHelper.CommentService;

            var businessModel = model.ConvertToOptions();
            var newsPosts     = NewsPostService.GetNewsPostsWithAdminTools(businessModel);

            var newsPostAdminViews = new List <NewsPostAdminView>();

            foreach (NewsPost newsPost in newsPosts)
            {
                string newsPostAuthorName = adminService.GetAdmin(newsPost.AuthorId).Login;
                int    commentCount       = commentService.GetCommentCountByPostId(newsPost.Id);
                newsPostAdminViews.Add(new NewsPostAdminView(newsPost, newsPostAuthorName, commentCount));
            }
            model.Pages = businessModel.Pages;
            return(new NewsPostAdminCollection(newsPostAdminViews, model));
        }