public bool CreateCommentFromPost(int contentId, DisqusPost post) { var posts = _orchardServices.ContentManager .Query<DisqusPostMappingPart, DisqusPostMappingRecord>() .Where(p => p.PostId == post.Id); if (posts.Count() > 0) { return false; } var commentPart = _orchardServices.ContentManager.New<CommentPart>("Comment"); commentPart.Author = post.Author.Name; commentPart.CommentText = post.Message; commentPart.CommentedOn = contentId; commentPart.Email = post.Author.Email; commentPart.SiteName = post.Author.Url; commentPart.CommentDateUtc = post.CreatedAt; commentPart.Status = CommentStatus.Approved; var record = new DisqusPostMappingRecord { PostId = post.Id, ContentItemRecord = commentPart.ContentItem.Record }; _postMappingRepository.Create(record); return true; }
public bool CreateCommentFromPost(int contentId, DisqusPost post) { var posts = _orchardServices.ContentManager .Query<DisqusPostMappingPart, DisqusPostMappingRecord>() .Where(p => p.PostId == post.Id); if (posts.Count() > 0) { return false; } // EMS CHANGE - start //var context = new CreateCommentContext //{ // Author = post.Author.Name, // CommentText = post.Message, // CommentedOn = contentId, // Email = post.Author.Email, // SiteName = post.Author.Url, //}; var commentContentItem = _orchardServices.ContentManager.New("Comment"); var commentPart = commentContentItem.As<CommentPart>(); if (commentPart != null) { commentPart.Author = post.Author.Name; commentPart.CommentText = post.Message; commentPart.CommentedOn = contentId; commentPart.Email = post.Author.Email; commentPart.SiteName = post.Author.Url; commentPart.Record.CommentDateUtc = post.CreatedAt; commentPart.Record.Status = CommentStatus.Approved; _orchardServices.ContentManager.Publish(commentContentItem); var record = new DisqusPostMappingRecord { PostId = post.Id, ContentItemRecord = commentPart.ContentItem.Record }; _postMappingRepository.Create(record); return true; } //var commentPart = _commentService.CreateComment(context, false); //commentPart.Record.CommentDateUtc = post.CreatedAt; //commentPart.Record.Status = CommentStatus.Approved; //var record = new DisqusPostMappingRecord { PostId = post.Id, ContentItemRecord = commentPart.ContentItem.Record }; //_postMappingRepository.Create(record); //return true; // If we made it this far, something went wrong return false; // EMS CHANGE - end }