Пример #1
0
        /// <summary>
        /// Returns the photo for a card, depending on the gender, reverting to a default one if unspecified.
        /// </summary>
        string GetPhoto(string actual, bool gender)
        {
            var defaultPhoto = gender
                ? "~/assets/img/unknown-male.png"
                : "~/assets/img/unknown-female.png";

            var photo = StringHelper.Coalesce(MediaPresenterService.GetSizedMediaPath(actual, MediaSize.Small), defaultPhoto);

            return(_url.Content(photo));
        }
Пример #2
0
 /// <summary>
 /// Maps a page excerpt to the page title.
 /// </summary>
 private PageTitleExtendedVM Map(RelationContext.PageExcerpt page)
 {
     return(new PageTitleExtendedVM
     {
         Id = page.Id,
         Key = page.Key,
         Title = page.Title,
         Type = page.Type,
         MainPhotoPath = MediaPresenterService.GetSizedMediaPath(page.MainPhotoPath, MediaSize.Small)
     });
 }
Пример #3
0
        /// <summary>
        /// Returns the info block for a constructed page.
        /// </summary>
        public async Task <InfoBlockVM> GetPageInfoBlockAsync(Page page)
        {
            var factGroups = GetPersonalFacts(page).ToList();
            var relations  = await _relations.GetRelationsForPage(page.Id);

            return(new InfoBlockVM
            {
                Photo = MediaPresenterService.GetMediaThumbnail(page.MainPhoto, MediaSize.Medium),
                Facts = factGroups,
                RelationGroups = relations,
            });
        }
Пример #4
0
        /// <summary>
        /// Returns the list of media files.
        /// </summary>
        public async Task <PageMediaVM> GetPageMediaAsync(string key)
        {
            var page = await FindPageAsync(key, q => q.Include(p => p.MediaTags)
                                           .ThenInclude(t => t.Media));

            var media = page.MediaTags
                        .Where(x => x.Media.IsDeleted == false)
                        .Select(x => MediaPresenterService.GetMediaThumbnail(x.Media, MediaSize.Small))
                        .ToList();

            return(Configure(page, new PageMediaVM {
                Media = media
            }));
        }