Ejemplo n.º 1
0
 public CommentsBlockViewModel(ICommentableDocument commentableDocument)
 {
     DocumentId = commentableDocument.Id;
     Comments = commentableDocument.Comments;
     Form = new AddCommentFormViewModel();
 }
Ejemplo n.º 2
0
        public virtual ActionResult AddComment(string id, AddCommentFormViewModel form)
        {
            return Handle(
                () =>
                {
                    //ToDo: Test all these logined/unloginned cases
                    var author = form.Author;
                    if (UserIdOrDefault != null)
                        author = UserNameOrDefault;
                    var comment = new Comment(author, UserIdOrDefault, form.Text);
                    comment.Id = _documentStore.Conventions.GenerateDocumentKey(comment);

                    _documentStore.DatabaseCommands.Patch(
                        id,
                        new[]
                                {
                                    new PatchRequest()
                                        {
                                            Type = PatchCommandType.Add,
                                            Name = "Comments",
                                            Value = RavenJObject.FromObject(comment)
                                        }
                                });
                });
        }