public IActionResult ManageComments(string postid) { List <CommentAdminViewModel> comments = null; if (postid != null) { comments = blogManager.GetComments(postid, true).Select(comment => mapper.Map <CommentAdminViewModel>(comment)).ToList(); } else { comments = blogManager.GetAllComments().Select(comment => mapper.Map <CommentAdminViewModel>(comment)).ToList(); } foreach (var cmt in comments) { cmt.Title = blogManager.GetBlogPostByGuid(new Guid(cmt.BlogPostId))?.Title; } return(View(comments.OrderBy(d => d.Date).ToList())); }