Copied to clipboard

Flag this post as spam?

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


  • Hryhorii 11 posts 132 karma points
    Nov 20, 2017 @ 14:34
    Hryhorii
    0

    UmbMapper for Archetype return null elements

    I have model Home

    public class HomeViewModel
     {
        public string Title { get; set; }
        public string Description { get; set; }
        public string MetaTitle { get; set; }
        public virtual IEnumerable<CarouselItem> Carousel { get; set; }
     }
    

    I have Carouse model

      public class CarouselItem
        {
            public string Image { get; set; }
            public string Title { get; set; }    
            public string Text { get; set; }
        }
    

    My mapper configs

    HomeMap

     public class HomeMap : UmbMapperConfig<HomeViewModel>
     {
         public HomeMap()
         {
             this.AddMap(item => item.Title);
             this.AddMap(item => item.MetaTitle);
             this.AddMap(item => item.Description);
             this.AddMap(item => item.Carousel).SetMapper<ArchetypeFactoryPropertyMapper>();
         }
     }
    

    and CarouselMap

    public class CarouselMap : UmbMapperConfig<CarouselItem>
    {
        public CarouselMap()
        {
            this.AddMap(item => item.Image).SetMapper<UmbracoPickerPropertyMapper>();
            this.AddMap(item => item.Title);
            this.AddMap(item => item.Text);
        }
    }
    

    My Action where I make map

    public override ActionResult Index(RenderModel model)
    {
        var viewModel = model.Content.MapTo(typeof(HomeViewModel));
    
        return CurrentTemplate(viewModel);
    }
    

    But for Carousel I get null in list

    enter image description here

    Could you explain me, what I should to do wrong?

  • Alex Skrypnyk 4516 posts 16141 karma points MVP admin
    Feb 14, 2018 @ 16:46
    Alex Skrypnyk
    0

    Hi Hryhorii

    Did you find a solution to this issue? Can you share with our community?

    /Oleksandr

  • Hryhorii 11 posts 132 karma points
    Feb 14, 2018 @ 17:01
    Hryhorii
    100

    It was different versions. We do not using Archetype on our project.

    But we are using Document Type + Nested Content

  • Alex Skrypnyk 4516 posts 16141 karma points MVP admin
    Feb 14, 2018 @ 17:37
    Alex Skrypnyk
    0

    Thanks for sharing the case. Have a great evening!

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft