public IActionResult Comment(Guid postid) { // TODO are comments enabled? Entry entry = blogManager.GetBlogPost(postid.ToString(), null); // TODO this method should respect paths that include the date ListPostsViewModel lpvm = new ListPostsViewModel(); lpvm.Posts = new List <PostViewModel> { mapper.Map <PostViewModel>(entry) }; ListCommentsViewModel lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(postid.ToString(), false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = postid.ToString() }; lpvm.Posts.First().Comments = lcvm; SinglePost(lpvm.Posts.First()); return(View("page", lpvm)); }
public IActionResult Comment(Guid postid) { ListPostsViewModel lpvm = null; var entry = blogManager.GetBlogPost(postid.ToString(), null); if (entry != null) { lpvm = new ListPostsViewModel { Posts = new List <PostViewModel> { mapper.Map <PostViewModel>(entry) } }; if (dasBlogSettings.SiteConfiguration.EnableComments) { var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(postid.ToString(), false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = postid.ToString(), PostDate = entry.CreatedUtc }; lpvm.Posts.First().Comments = lcvm; } } return(SinglePostView(lpvm)); }
public IActionResult PostGuid(Guid postid) { var lpvm = new ListPostsViewModel(); var entry = blogManager.GetBlogPostByGuid(postid); if (entry != null) { var pvm = mapper.Map <PostViewModel>(entry); var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(entry.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = entry.EntryId, PostDate = entry.CreatedUtc, CommentUrl = dasBlogSettings.GetCommentViewUrl(entry.Title), ShowComments = dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry, AllowComments = entry.AllowComments }; pvm.Comments = lcvm; lpvm.Posts = new List <PostViewModel>() { pvm }; return(SinglePostView(lpvm)); } else { return(NotFound()); } }
public IActionResult Comment(Guid postid) { // TODO are comments enabled? Entry entry = _blogManager.GetBlogPost(postid.ToString()); ListPostsViewModel lpvm = new ListPostsViewModel(); lpvm.Posts = new List <PostViewModel> { _mapper.Map <PostViewModel>(entry) }; ListCommentsViewModel lcvm = new ListCommentsViewModel { Comments = _blogManager.GetComments(postid.ToString(), false) .Select(comment => _mapper.Map <CommentViewModel>(comment)).ToList(), PostId = postid.ToString() }; lpvm.Posts.First().Comments = lcvm; SinglePost(lpvm.Posts.First()); return(View("page", lpvm)); }
public IActionResult Post(string posttitle, string day, string month, string year) { var lpvm = new ListPostsViewModel(); var postDtTime = DateTime.MinValue; var dayYear = 0; if (dasBlogSettings.SiteConfiguration.EnableTitlePermaLinkUnique) { dayYear = Convert.ToInt32(string.Format("{0}{1}{2}", year, month, day)); } var routeAffectedFunctions = new RouteAffectedFunctions(dasBlogSettings.SiteConfiguration.EnableTitlePermaLinkUnique); if (!routeAffectedFunctions.IsValidDay(dayYear)) { return(NotFound()); } var dt = routeAffectedFunctions.ConvertDayToDate(dayYear); if (routeAffectedFunctions.IsSpecificPostRequested(posttitle, dayYear)) { var entry = blogManager.GetBlogPost(posttitle, dt); if (entry != null) { var pvm = mapper.Map <PostViewModel>(entry); var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(entry.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = entry.EntryId, PostDate = entry.CreatedUtc, CommentUrl = dasBlogSettings.GetCommentViewUrl(posttitle), ShowComments = dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry }; pvm.Comments = lcvm; if (httpContextAccessor.HttpContext.Request.Path.Value.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase)) { return(RedirectPermanent(pvm.PermaLink)); } lpvm.Posts = new List <PostViewModel>() { pvm }; return(SinglePostView(lpvm)); } else { return(NotFound()); } } else { return(RedirectToAction("index", "home")); } }
public async Task <IActionResult> Get(Guid id) { var model = new ListCommentsViewModel(); IList <Comment> comments = await _commentService.GetComments(id); model.Comments = _mapper.Map <IList <Comment>, List <CommentViewModel> >(comments); return(Ok(model.Comments)); }
public ViewResult Comments(string Slug, string listName) { var list = _context.Lists.Where(m => m.Slug == listName).FirstOrDefault(); var comments = _context.Reviews.Include(r => r.List).Where(r => r.List == list).OrderByDescending(x => x.CreatedAt).ToList(); ListCommentsViewModel listCommentsViewModel = new ListCommentsViewModel { Comments = comments, List = list }; return(View(listCommentsViewModel)); }
public IActionResult Comment(string posttitle, string day, string month, string year) { ListPostsViewModel lpvm = null; NBR.Entry entry = null; var postguid = Guid.Empty; var uniquelinkdate = ValidateUniquePostDate(year, month, day); entry = blogManager.GetBlogPost(posttitle, uniquelinkdate); if (entry == null && Guid.TryParse(posttitle, out postguid)) { entry = blogManager.GetBlogPostByGuid(postguid); var pvm = mapper.Map <PostViewModel>(entry); return(RedirectPermanent(dasBlogSettings.GetCommentViewUrl(pvm.PermaLink))); } if (entry != null) { lpvm = new ListPostsViewModel { Posts = new List <PostViewModel> { mapper.Map <PostViewModel>(entry) } }; if (dasBlogSettings.SiteConfiguration.EnableComments) { var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(entry.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = entry.EntryId, PostDate = entry.CreatedUtc, CommentUrl = dasBlogSettings.GetCommentViewUrl(posttitle), ShowComments = true, AllowComments = entry.AllowComments }; lpvm.Posts.First().Comments = lcvm; } } return(SinglePostView(lpvm)); }
private ListPostsViewModel AddComments(ListPostsViewModel listPostsViewModel) { foreach (var post in listPostsViewModel.Posts) { var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(post.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = post.EntryId, PostDate = post.CreatedDateTime, CommentUrl = dasBlogSettings.GetCommentViewUrl(post.PermaLink) }; post.Comments = lcvm; } return(listPostsViewModel); }
public IActionResult CommentError(AddCommentViewModel comment, List <string> errors) { ListPostsViewModel lpvm = null; NBR.Entry entry = null; var postguid = Guid.Parse(comment.TargetEntryId); entry = blogManager.GetBlogPostByGuid(postguid); if (entry != null) { lpvm = new ListPostsViewModel { Posts = new List <PostViewModel> { mapper.Map <PostViewModel>(entry) } }; if (dasBlogSettings.SiteConfiguration.EnableComments) { var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(entry.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = entry.EntryId, PostDate = entry.CreatedUtc, CommentUrl = dasBlogSettings.GetCommentViewUrl(comment.TargetEntryId), ShowComments = true, AllowComments = entry.AllowComments }; if (comment != null) { lcvm.CurrentComment = comment; } lpvm.Posts.First().Comments = lcvm; if (errors != null && errors.Count > 0) { lpvm.Posts.First().ErrorMessages = errors; } } } return(SinglePostView(lpvm)); }
public IActionResult Post(string posttitle, string day, string month, string year) { var lpvm = new ListPostsViewModel(); var uniquelinkdate = ValidateUniquePostDate(year, month, day); var entry = blogManager.GetBlogPost(posttitle, uniquelinkdate); if (entry != null) { var pvm = mapper.Map <PostViewModel>(entry); var lcvm = new ListCommentsViewModel { Comments = blogManager.GetComments(entry.EntryId, false) .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(), PostId = entry.EntryId, PostDate = entry.CreatedUtc, CommentUrl = dasBlogSettings.GetCommentViewUrl(posttitle), ShowComments = dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry, AllowComments = entry.AllowComments }; pvm.Comments = lcvm; if (!dasBlogSettings.SiteConfiguration.UseAspxExtension && httpContextAccessor.HttpContext.Request.Path.Value.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase)) { return(RedirectPermanent(pvm.PermaLink)); } lpvm.Posts = new List <PostViewModel>() { pvm }; return(SinglePostView(lpvm)); } else { return(RedirectToAction("index", "home")); } }