Пример #1
0
        public DiscussionFolderContract(DiscussionFolder folder, DiscussionFolderOptionalFields fields,
                                        IUserIconFactory userIconFactory)
        {
            ParamIs.NotNull(() => folder);

            this.Description = folder.Description;
            this.Id          = folder.Id;
            this.Name        = folder.Name;

            if (fields.HasFlag(DiscussionFolderOptionalFields.LastTopic) && folder.Topics.Any())
            {
                var lastTopic = folder.Topics.ToArray().MaxItem(t => t.Created);

                LastTopicAuthor = new UserWithIconContract(lastTopic.Author, lastTopic.AuthorName, userIconFactory);
                LastTopicDate   = folder.Topics.Max(t => t.Created);
            }

            if (fields.HasFlag(DiscussionFolderOptionalFields.TopicCount))
            {
                this.TopicCount = folder.Topics.Count();
            }
        }
Пример #2
0
        public DiscussionFolderContract(DiscussionFolder folder, DiscussionFolderOptionalFields fields,
                                        IUserIconFactory userIconFactory)
        {
            ParamIs.NotNull(() => folder);

            Description = folder.Description;
            Id          = folder.Id;
            Name        = folder.Name;

            if (fields.HasFlag(DiscussionFolderOptionalFields.LastTopic) && folder.Topics.Any())
            {
                var lastTopic = folder.Topics.ToArray().MaxItem(t => t.Created);

                LastTopicAuthor = new UserForApiContract(lastTopic.Author, lastTopic.AuthorName, userIconFactory, UserOptionalFields.MainPicture);
                LastTopicDate   = folder.Topics.Max(t => t.Created).ToUniversalTime();
            }

            if (fields.HasFlag(DiscussionFolderOptionalFields.TopicCount))
            {
                TopicCount = folder.Topics.Count();
            }
        }