private void ContentService_Trashing(IContentService sender, MoveEventArgs <IContent> e)
        {
            var service = new UmbracoFormsBlogCommentsService();

            foreach (var info in e.MoveInfoCollection)
            {
                var entity = info.Entity;

                if (entity.ContentType.Alias != ArticulateMarkdown.ModelTypeAlias && entity.ContentType.Alias != ArticulateRichText.ModelTypeAlias)
                {
                    break;
                }

                var blogRoot = entity.Ancestors().FirstOrDefault(x => x.ContentType.Alias == ArticulateModel.ModelTypeAlias);

                if (blogRoot == null)
                {
                    break;
                }
                var blogCommentForm = blogRoot.GetValue <Guid>("commentsForm");

                if (blogCommentForm == default(Guid))
                {
                    break;
                }

                service.DeleteComments(entity.Id, blogCommentForm);
            }
        }
Пример #2
0
        public ActionResult RenderCommentsList()
        {
            var service = new UmbracoFormsBlogCommentsService();

            var formId = CurrentPage.GetPropertyValue <Guid>("commentsForm", true);

            if (formId == default(Guid))
            {
                return(EmptyResult());
            }

            var comments = service.GetComments(CurrentPage.Id, formId);

            if (ExistenceUtility.IsNullOrEmpty(comments))
            {
                return(EmptyResult());
            }

            return(PartialView("~/Views/Partials/Blog/CommentsList.cshtml", comments));
        }