Exemplo n.º 1
0
    /// <inheritdoc />
    public IEnumerable <IPublishedContent> GetMediaByTag(string tag, string?group = null, string?culture = null)
    {
        IEnumerable <int> ids = _tagService.GetTaggedMediaByTag(tag, group, culture)
                                .Select(x => x.EntityId);

        return(_contentQuery.Media(ids));
    }
Exemplo n.º 2
0
        public SpeakersApiModel GetSpeakers()
        {
            var speakersNode = _content.ContentAtRoot().OfType <Speakers>().FirstOrDefault();
            var speakers     = new SpeakersApiModel();
            var speakerList  = new List <SpeakerApiModel>();

            if (speakersNode != null)
            {
                //ToDo: Use UmbarcoMapper here?
                foreach (var speaker in speakersNode.Children.OfType <Speaker>().OrderBy(s => s.Name))
                {
                    var image = speaker.Picture == null ? null : _content.Media(speaker.Picture.Id) as Image;                    // ToDo: is this the right way to cast a media type? Wasn't there a more elegant way like TypeMedia?
                    speakerList.Add(new SpeakerApiModel()
                    {
                        Name        = speaker.Name,
                        Description = speaker.ShortDescription,
                        JobJobTitle = speaker.JobTitle,
                        Company     = speaker.Company,
                        PictureUrl  = image?.UmbracoFile.Src
                    });
                }
                speakers.Name        = speakersNode.Name;
                speakers.Description = speakersNode.Description;
                speakers.Speakers    = speakerList;
            }

            return(speakers);
        }
        public vmBlock_DataLink Convert(Link link, UmbracoMappingContext context)
        {
            if (link != null)
            {
                if (link.Type == LinkType.External)
                {
                    return(new vmBlock_DataLink()
                    {
                        Title = link.Name,
                        Label = link.Name,
                        Href = link.Url,
                        IsExternalLink = true,
                        IsNewTab = link.Target == "_blank"
                    });
                }
                else
                {
                    var id = link.Udi as GuidUdi;
                    if (id != null)
                    {
                        var content = contentQuery.Content(id);

                        if (content != null)
                        {
                            var name = string.IsNullOrEmpty(link.Name) ? content.Name : link.Name;
                            var udi  = context.Model != null ? new GuidUdi("document", context.Model.Key) : null;

                            var d = new vmBlock_DataLink()
                            {
                                Title    = name,
                                Label    = name,
                                Href     = link.Url,
                                IsActive = link.Udi == udi,
                                IsNewTab = link.Target == "_blank"
                            };
                            return(d);
                        }

                        var media = contentQuery.Media(id);

                        if (media != null)
                        {
                            var name = string.IsNullOrEmpty(link.Name) ? media.Name : link.Name;

                            var d = new vmBlock_DataLink()
                            {
                                Title    = name,
                                Label    = name,
                                Href     = media.Url(),
                                IsNewTab = link.Target == "_blank"
                            };
                            return(d);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        // Method One
        private string GetMediaFromPublishedContentQuery()
        {
            var willBeEMpty    = _publishedContentQuery.Content(2181)?.Url();
            var cheerleaderUrl = _publishedContentQuery.Media(2181)?.Url();

            //  _contentService.GetById(2182).?.Url();  HAS NO URL as it might not be published!!!

            return(cheerleaderUrl);
        }