Beispiel #1
0
        public FullscreenPostPartDTO GetPostPartWithVideo(PostDTO post)
        {
            var postWithVideo = PostMapper.ConvertToFullscreenPostPartWithNoContent(post);

            postWithVideo.VideoUrl          = post.VideoUrl;
            postWithVideo.ContentType       = ContentType.Video;
            postWithVideo.DurationInSeconds = post.DurationInSeconds;

            return(postWithVideo);
        }
Beispiel #2
0
        public FullscreenPostPartDTO GetPostWithTitle(PostDTO post)
        {
            var postWithTitle = PostMapper.ConvertToFullscreenPostPartWithNoContent(post);

            postWithTitle.Title             = post.Title;
            postWithTitle.ContentType       = ContentType.Title;
            postWithTitle.DurationInSeconds = _batchOptions.Value.TitlePostPartDurationInSeconds;

            return(postWithTitle);
        }
Beispiel #3
0
        public IEnumerable <FullscreenPostPartDTO> GetPostPartsWithImages(PostDTO post)
        {
            var postContainsImages = post.Files.Any();

            if (postContainsImages)
            {
                var imagePartsPerPost = _batchOptions.Value.FullscreenMaxImagePerPostNumber;
                if (imagePartsPerPost == 0)
                {
                    imagePartsPerPost = 1;
                }

                var selectedPortionOfFiles = post.Files.OrderBy(x => new Random().Next()).ToList();

                selectedPortionOfFiles.Remove(post.Files.First());
                selectedPortionOfFiles = selectedPortionOfFiles.Prepend(post.Files.First()).ToList();

                selectedPortionOfFiles = selectedPortionOfFiles.Take(imagePartsPerPost).ToList();

                foreach (var file in selectedPortionOfFiles)
                {
                    var postWithImage = PostMapper.ConvertToFullscreenPostPartWithNoContent(post);
                    postWithImage.File = file;

                    var isFirstImage = file == post.Files.First();
                    if (isFirstImage)
                    {
                        postWithImage.Title             = post.Title;
                        postWithImage.ContentType       = ContentType.TitleImage;
                        postWithImage.DurationInSeconds = _batchOptions.Value.TitlePostPartDurationInSeconds;
                    }
                    else
                    {
                        postWithImage.ContentType       = ContentType.Image;
                        postWithImage.DurationInSeconds = _batchOptions.Value.ImagePostPartDurationInSeconds;
                    }

                    yield return(postWithImage);
                }
            }
        }