예제 #1
0
 public CommentsViewInfo GetAddCommentsInfo(Webpage webpage)
 {
     if (!webpage.AreCommentsEnabled(_getWebpageCommentingInfo.Get(webpage), _settings))
     {
         return new CommentsViewInfo { Disabled = true };
     }
     if (!_settings.AllowGuestComments && CurrentRequestData.CurrentUser == null)
     {
         return new CommentsViewInfo
                {
                    View = "Login",
                    Model = new LoginModel(),
                };
     }
     if (CurrentRequestData.CurrentUser == null)
     {
         return new CommentsViewInfo
                {
                    View = "Guest",
                    Model = new GuestAddCommentModel { WebpageId = webpage.Id },
                };
     }
     return new CommentsViewInfo
            {
                View = "LoggedIn",
                Model = new LoggedInUserAddCommentModel { WebpageId = webpage.Id },
            };
 }
예제 #2
0
 public CommentsViewInfo GetShowCommentsInfo(Webpage webpage)
 {
     if (!webpage.AreCommentsEnabled(_getWebpageCommentingInfo.Get(webpage), _settings))
     {
         return new CommentsViewInfo { Disabled = true };
     }
     var showCommentsInfo = new CommentsViewInfo
                            {
                                View = "Show",
                                Model =
                                    _session.QueryOver<Comment>()
                                    .Where(
                                        comment =>
                                    comment.Webpage == webpage && comment.Approved == true &&
                                    comment.InReplyTo == null)
                                    //.Take(_settings.InitialNumberOfCommentsToShow)
                                    .List(),
                            };
     showCommentsInfo.ViewData["allow-reply"] = _settings.AllowGuestComments ||
                                                CurrentRequestData.CurrentUser != null;
     showCommentsInfo.ViewData["webpage"] = webpage;
     return showCommentsInfo;
 }