Ejemplo n.º 1
0
 public PostCommentResponse AddGuestComment(GuestAddCommentModel model)
 {
     if (_settings.AllowGuestComments)
     {
         var comment = new Comment
         {
             Email    = model.Email,
             Name     = model.Name,
             Message  = model.Message,
             Webpage  = GetWebpage(model),
             Approved =
                 _settings.CommentApprovalType == CommentApprovalType.None
                                   ? true
                                   : (bool?)null,
             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
     });
 }
Ejemplo n.º 2
0
 public ActionResult Guest([IoCModelBinder(typeof(SetIPAddressModelBinder))] GuestAddCommentModel model)
 {
     if (ModelState.IsValid)
     {
         PostCommentResponse response = _commentsUiService.AddGuestComment(model);
         return(RedirectToPage(response));
     }
     return(RedirectToPage(new PostCommentResponse {
         Valid = false, RedirectUrl = Referrer.ToString()
     }));
 }