Esempio n. 1
0
 public void SetUp()
 {
     user   = CreateEntry.User();
     folder = new DiscussionFolder("Test folder");
     repo   = new FakeDiscussionFolderRepository(folder);
     repo.Save(user);
     queries = new DiscussionQueries(repo, new FakePermissionContext(user), new FakeUserIconFactory(), new FakeEntryLinkFactory());
 }
Esempio n. 2
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();
            }
        }
Esempio n. 3
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();
            }
        }