public static string MarkAsSolution(string pageId) { if (MembershipHelper.IsAuthenticated()) { var m = Member.GetCurrentMember(); var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(pageId))); if (forumPost != null) { var forumTopic = _mapper.MapForumTopic(new Node(forumPost.ParentId.ToInt32())); // If this current member id doesn't own the topic then ignore, also // if the topic is already solved then ignore. if (m.Id == forumTopic.Owner.MemberId && !forumTopic.IsSolved) { // Get a user to save both documents with var usr = new User(0); // First mark the post as the solution var p = new Document(forumPost.Id); p.getProperty("forumPostIsSolution").Value = 1; p.Publish(usr); library.UpdateDocumentCache(p.Id); // Now update the topic var t = new Document(forumTopic.Id); t.getProperty("forumTopicSolved").Value = 1; t.Publish(usr); library.UpdateDocumentCache(t.Id); return(library.GetDictionaryItem("Updated")); } } } return(library.GetDictionaryItem("Error")); }
/// <summary> /// Returns a list of posts from a parent topic /// </summary> /// <param name="topicNodeId"></param> /// <param name="useNodeFactory"></param> /// <returns></returns> public IEnumerable <ForumPost> ReturnAllPostsInTopic(int topicNodeId, bool useNodeFactory = false) { if (useNodeFactory | UseNodeFactoryForAllQueries) { return(ReturnAllPostsInTopic_NodeFactory(topicNodeId)); } var criteria = ExamineManager.Instance.SearchProviderCollection[ExamineSearcher].CreateSearchCriteria(); var query = criteria.Field("forumPostParentID", topicNodeId.ToString()) .And().NodeTypeAlias(NodeTypePost); var results = ExamineManager.Instance.SearchProviderCollection[ExamineSearcher].Search(query.Compile()); return(results.Select(searchResult => Mapper.MapForumPost(searchResult)).OrderBy(x => x.CreatedOn)); }