public PartialFindResult <DiscussionTopicContract> GetTopics( int?folderId = null, int start = 0, int maxResults = DefaultMax, bool getTotalCount = false, DiscussionTopicSortRule sort = DiscussionTopicSortRule.DateCreated, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) { return(HandleQuery(ctx => { var query = ctx.OfType <DiscussionTopic>() .Query() .WhereNotDeleted() .WhereIsInFolder(folderId); var topics = query .OrderBy(sort) .Paged(new PagingProperties(start, maxResults, getTotalCount)) .ToArray() .Select(f => new DiscussionTopicContract(f, _userIconFactory, fields)) .ToArray(); var count = (getTotalCount ? query.Count() : 0); return PartialFindResult.Create(topics, count); })); }
public DiscussionTopicContract GetTopic(int topicId, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) { return(HandleQuery(ctx => { return new DiscussionTopicContract(ctx.OfType <DiscussionTopic>().Load(topicId), userIconFactory, fields); })); }
public IEnumerable <DiscussionTopicContract> GetTopicsForFolder(int folderId, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) { return(HandleQuery(ctx => { var folder = ctx.Load(folderId); return folder.Topics .Select(t => new DiscussionTopicContract(t, userIconFactory, fields)) .OrderByDescending(t => t.LastComment != null ? t.LastComment.Created : t.Created) .ToArray(); })); }
public DiscussionTopicContract GetTopic(int topicId, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) => _queries.GetTopic(topicId, fields);
public IEnumerable <DiscussionTopicContract> GetTopicsForFolder(int folderId, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) => _queries.GetTopicsForFolder(folderId, fields);
public PartialFindResult <DiscussionTopicContract> GetTopics( int?folderId = null, int start = 0, int maxResults = DefaultMax, bool getTotalCount = false, DiscussionTopicSortRule sort = DiscussionTopicSortRule.DateCreated, DiscussionTopicOptionalFields fields = DiscussionTopicOptionalFields.None) => _queries.GetTopics(folderId, start, maxResults, getTotalCount, sort, fields);
public DiscussionTopicContract(DiscussionTopic topic, IUserIconFactory userIconFactory, DiscussionTopicOptionalFields fields) { ParamIs.NotNull(() => topic); Author = new UserWithIconContract(topic.Author, userIconFactory); Created = topic.Created; FolderId = topic.Folder.Id; Id = topic.Id; Name = topic.Name; if (fields.HasFlag(DiscussionTopicOptionalFields.Comments)) { Comments = topic.Comments.Select(c => new CommentForApiContract(c, userIconFactory)).ToArray(); } if (fields.HasFlag(DiscussionTopicOptionalFields.CommentCount)) { CommentCount = topic.Comments.Count; } if (fields.HasFlag(DiscussionTopicOptionalFields.Content)) { Content = topic.Content; } if (fields.HasFlag(DiscussionTopicOptionalFields.LastComment) && topic.Comments.Any()) { LastComment = new CommentForApiContract(topic.Comments.MaxItem(c => c.Created), userIconFactory, includeMessage: false); } }