Example #1
0
        public PostCommentResponse AddLoggedInComment(LoggedInUserAddCommentModel model)
        {
            User currentUser = CurrentRequestData.CurrentUser;

            if (IsValid(model) && currentUser != null)
            {
                var comment = new Comment
                {
                    User      = currentUser,
                    Name      = currentUser.GetCommentsInfo().Username,
                    Email     = currentUser.Email,
                    Message   = model.Message,
                    Webpage   = GetWebpage(model),
                    Approved  = _settings.CommentApprovalType == CommentApprovalType.All ? (bool?)null : true,
                    InReplyTo = GetInReplyTo(model),
                    IPAddress = model.IPAddress,
                    SendReplyNotifications = model.ReplyNotification
                };
                AddNewCommentToReplyChildren(comment);
                _session.Transact(session => session.Save(comment));
                return(GetResponse(comment));
            }
            return(new PostCommentResponse {
                Valid = false
            });
        }
Example #2
0
 public ActionResult LoggedIn([IoCModelBinder(typeof(SetIPAddressModelBinder))] LoggedInUserAddCommentModel model)
 {
     if (ModelState.IsValid)
     {
         PostCommentResponse response = _commentsUiService.AddLoggedInComment(model);
         return(RedirectToPage(response));
     }
     return(RedirectToPage(new PostCommentResponse {
         Valid = false, RedirectUrl = Referrer.ToString()
     }));
 }