Ejemplo n.º 1
0
        public ActionResult AddCommentAjax(CreateMindViewModel model, Guid commentedMessageId)
        {
            var     timelineUserId = this.CurrentUserSessionContext().UserId;
            Message message        = _messageService.CreateComment(model.Mind, timelineUserId, commentedMessageId);

            if (message != null)
            {
                _unitOfWork.Commit();
                _userMessageService.PublishMessage(message);

                _messageService.ReloadMessage(message);
                var watcherUserId = timelineUserId;
                MessageViewModel commentMessageViewModel = _messagesViewModelService.CreateMessageViewModel(message, timelineUserId, watcherUserId);

                Message orginalMessage = _messageService.FindById(commentedMessageId);
                _messageService.ReloadMessage(orginalMessage);
                MessageViewModel orginalMessageViewModel = _messagesViewModelService.CreateMessageViewModel(orginalMessage, timelineUserId, watcherUserId);

                string commentView         = this.RenderRazorViewToString("_UserMessageCommentPartial", commentMessageViewModel);
                string commentedActionView = this.RenderRazorViewToString("_UserMessageActionsPartial", orginalMessageViewModel);

                return(Json(new { @success = true, @commentedMessageId = commentedMessageId, @commentedActionView = commentedActionView, @commentView = commentView }));
            }

            return(Json(new { @success = false, @error = "Some data are incorrect." }));
        }
Ejemplo n.º 2
0
        public ActionResult AddQuoteAjax(CreateMindViewModel model, Guid quotedMessageId)
        {
            var     timelineUserId = this.CurrentUserSessionContext().UserId;
            Message message        = _messageService.CreateQuote(model.Mind, timelineUserId, quotedMessageId);

            if (message != null)
            {
                _unitOfWork.Commit();
                _userMessageService.PublishMessage(message);

                _messageService.ReloadMessage(message);
                var watcherUserId = timelineUserId;
                MessageViewModel messageViewModel = _messagesViewModelService.CreateMessageViewModel(message, timelineUserId, watcherUserId, true);
                string           mindView         = this.RenderRazorViewToString("_UserMessageMindPartial", messageViewModel);
                return(Json(new { @success = true, @view = mindView, messageId = message.Id }));
            }

            return(Json(new { @success = false, @error = "Some data are incorrect." }));
        }