Example #1
0
        public ITentRequestDate FromPost(ITentRequestPost post, TentFeedRequestSort sortBy)
        {
            Ensure.Argument.IsNotNull(post, nameof(post));
            Ensure.Argument.IsNotNull(post.Post, nameof(post.Post));

            // Create the resulting Request Date object.
            var result = new TentRequestDate(this.uriHelpers)
            {
                Version = post.Post.Version.Id
            };

            // Pick the correct date on the specified post.
            switch (sortBy)
            {
                case TentFeedRequestSort.VersionPublishedAt:
                    result.Date = post.Post.Version.PublishedAt.GetValueOrDefault();
                    break;
                case TentFeedRequestSort.VersionReceivedAt:
                    result.Date = post.Post.Version.ReceivedAt.GetValueOrDefault();
                    break;
                case TentFeedRequestSort.PublishedAt:
                    result.Date = post.Post.PublishedAt.GetValueOrDefault();
                    break;
                default:
                    result.Date = post.Post.ReceivedAt.GetValueOrDefault();
                    break;
            }

            return result;
        }
Example #2
0
 public ITentFeedRequest SortBy(TentFeedRequestSort newSortBy)
 {
     this.sortBy = newSortBy;
     return this;
 }