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"));
        }
Exemple #2
0
        /// <summary>
        /// Returns a list of topics within a category
        /// </summary>
        /// <param name="categoryNodeId"></param>
        /// <param name="sortByLastPostDate"> </param>
        /// <param name="useNodeFactory"> </param>
        /// <returns></returns>
        public IEnumerable <ForumTopic> ReturnAllTopicsInCategory(int categoryNodeId, bool sortByLastPostDate = false, bool useNodeFactory = false)
        {
            if (useNodeFactory | UseNodeFactoryForAllQueries)
            {
                return(ReturnAllTopicsInCategory_NodeFactory(categoryNodeId, sortByLastPostDate));
            }

            var criteria = ExamineManager.Instance.SearchProviderCollection[ExamineSearcher].CreateSearchCriteria();
            var query    = criteria.Field("forumTopicParentCategoryID", categoryNodeId.ToString())
                           .And().NodeTypeAlias(NodeTypeTopic);
            var results = ExamineManager.Instance.SearchProviderCollection[ExamineSearcher].Search(query.Compile());

            return(results.Select(searchResult => Mapper.MapForumTopic(searchResult)).OrderByDescending(x => sortByLastPostDate ? x.LastPostDate : x.CreatedOn));
        }