예제 #1
0
        public static HtmlTag PreviousAndNextPostsDiv(DailyPhotosPage photoPage)
        {
            if (photoPage.PreviousDailyPhotosPage == null && photoPage.NextDailyPhotosPage == null)
            {
                return(HtmlTag.Empty());
            }

            var hasPreviousPosts            = photoPage.PreviousDailyPhotosPage != null;
            var hasLaterPosts               = photoPage.NextDailyPhotosPage != null;
            var hasBothEarlierAndLaterPosts = hasPreviousPosts && hasLaterPosts;

            var relatedPostsContainer = new DivTag().AddClass("post-related-posts-container");

            relatedPostsContainer.Children.Add(new DivTag()
                                               .Text($"Daily Photos {(hasPreviousPosts ? "Before" : "")}" +
                                                     $"{(hasBothEarlierAndLaterPosts ? "/" : "")}{(hasLaterPosts ? "After" : "")}:")
                                               .AddClass("post-related-posts-label-tag"));

            if (hasPreviousPosts)
            {
                relatedPostsContainer.Children.Add(DailyPhotosPageRelatedContentDiv(photoPage.PreviousDailyPhotosPage));
            }

            if (hasLaterPosts)
            {
                relatedPostsContainer.Children.Add(DailyPhotosPageRelatedContentDiv(photoPage.NextDailyPhotosPage));
            }

            return(relatedPostsContainer);
        }
예제 #2
0
        public static async Task <DailyPhotosPage> DailyPhotoGallery(DateTime dateTimeForPictures,
                                                                     DateTime?generationVersion)
        {
            var db = await Db.Context();

            var startsAfterOrOn = dateTimeForPictures.Date;
            var endsBefore      = dateTimeForPictures.AddDays(1).Date;

            var datePhotos = await db.PhotoContents
                             .Where(x => x.PhotoCreatedOn >= startsAfterOrOn && x.PhotoCreatedOn < endsBefore)
                             .OrderBy(x => x.PhotoCreatedOn).ToListAsync();

            if (!datePhotos.Any())
            {
                return(null);
            }

            var photographersList = datePhotos.Where(x => !string.IsNullOrWhiteSpace(x.PhotoCreatedBy))
                                    .Select(x => x.PhotoCreatedBy).Distinct().ToList();
            var createdByList = datePhotos.Select(x => x.CreatedBy).Distinct().ToList();

            var photographersString             = photographersList.ToList().JoinListOfStringsToCommonUsageListWithAnd();
            var photographersAndCreatedByString = photographersList.Concat(createdByList).Distinct().ToList()
                                                  .JoinListOfStringsToCommonUsageListWithAnd();

            var photoPage = new DailyPhotosPage
            {
                MainImage = new PictureSiteInformation(datePhotos.First().ContentId),
                ImageList = datePhotos.Select(x => new PictureSiteInformation(x.ContentId)).ToList(),
                Title     = $"Photographs - {dateTimeForPictures:MMMM d, dddd, yyyy}",
                Summary   =
                    $"Photographs taken on {dateTimeForPictures:M/d/yyyy}{(photographersList.Any() ? " by " : "")}{photographersString}.",
                CreatedBy     = photographersAndCreatedByString,
                PhotoPageDate = startsAfterOrOn,
                SiteName      = UserSettingsSingleton.CurrentSettings().SiteName,
                PhotoTags     =
                    datePhotos.SelectMany(Db.TagListParseToSlugsAndIsExcluded).Distinct().OrderBy(x => x.TagSlug)
                    .ToList(),
                PageUrl           = UserSettingsSingleton.CurrentSettings().DailyPhotoGalleryUrl(startsAfterOrOn),
                GenerationVersion = generationVersion
            };

            return(photoPage);
        }
예제 #3
0
        public static HtmlTag DailyPhotosPageRelatedContentDiv(DailyPhotosPage photoPage)
        {
            if (photoPage == null)
            {
                return(HtmlTag.Empty());
            }

            var relatedPostContainerDiv = new DivTag().AddClass("related-post-container");

            var relatedPostMainPictureContentDiv = new DivTag().AddClass("related-post-image-content-container");

            relatedPostMainPictureContentDiv.Children.Add(Tags.PictureImgThumbWithLink(photoPage.MainImage.Pictures,
                                                                                       photoPage.PageUrl));

            relatedPostContainerDiv.Children.Add(relatedPostMainPictureContentDiv);

            var relatedPostMainTextContentDiv = new DivTag().AddClass("related-post-text-content-container");

            var relatedPostMainTextTitleTextDiv = new DivTag().AddClass("related-post-text-content-title-container");

            var relatedPostMainTextTitleLink =
                new LinkTag(photoPage.Title, photoPage.PageUrl).AddClass("related-post-text-content-title-link");

            relatedPostMainTextTitleTextDiv.Children.Add(relatedPostMainTextTitleLink);

            var relatedPostMainTextCreatedOrUpdatedTextDiv = new DivTag().AddClass("related-post-text-content-date")
                                                             .Text(Tags.LatestCreatedOnOrUpdatedOn(
                                                                       (ICreatedAndLastUpdateOnAndBy)photoPage.MainImage.Pictures.DbEntry)?.ToString("M/d/yyyy") ??
                                                                   string.Empty);

            relatedPostMainTextContentDiv.Children.Add(relatedPostMainTextTitleTextDiv);
            relatedPostMainTextContentDiv.Children.Add(relatedPostMainTextCreatedOrUpdatedTextDiv);

            relatedPostContainerDiv.Children.Add(relatedPostMainTextContentDiv);

            return(relatedPostContainerDiv);
        }