Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Overgaard 9 posts 41 karma points
    Oct 09, 2014 @ 09:27
    Martin Overgaard
    0

    Getting Media from code in repository

    Hi there,

    I'm working in Umbraco 7 and I'm trying to map data to a custom entity i have created. Mapping strings, int ect. is quite simple but can someone tell me how i can map content created from Media picker, Multi Media picker and Content picker?

    My simple model:

    public class Frontpage : Master
        {
            public string Headline { get; set; }
            public HtmlString Content { get; set; }
            public string Image { get; set; }

            public IEnumerable<XXXX> Images { get; set; } <-- What class/type should I place here (IMedia mayby)
            public IEnumerable<XXXX> Links { get; set; }    <-- What class/type should I place here (IContent mayby)
            public IEnumerable<NewsItem> News { get; set; }
        }

    In my repository I have this method:

    public Frontpage GetFrontPage(IPublishedContent content)
            {
                var imageObject = How do I map a image from image picker here
                var imagesObject = How do I map images from multi media picker here
                var linksObject = How do I map a multiple links from content picker here

                var model = new Frontpage {
                    Headline = !string.IsNullOrEmpty(content.GetPropertyValue<string>("headline")) ? content.GetPropertyValue<string>("headline") : content.Name,
                    Content = new HtmlString(content.GetPropertyValue<string>("content")),
                    Image = And finally what goes here,
                    Images = And finally what goes here,
                    Links = And finally what goes here,
                    News = null
                };

                return model;
            }

    I hope this makes sence to some of you guys/girls ;o)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies