In an Umbraco 7 controller I want to get carousel data from a CurrentPage and loop over it
var carousels = CurrentPage.GetProperty("carousels").Value;
carousels at this point is an object, but it should be a list of :
public class LearningPageCarousel
{
public string Title { get; set; }
public List<LearningLandingInfoCard> InfoCards = new List<LearningLandingInfoCard>();
}
I'm having trouble converting the object to the LearningPageCarousel type, is there a simple way to do this, or should I be getting the data from CurrentPage in a different way?
If anyone needs it here is the solution, I was casting incorrectly
var carousels = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("carousels");
foreach (var carousel in carousels)
{
LearningPageCarousel learningPageCarousel = new LearningPageCarousel();
learningPageCarousel.Title = carousel.GetPropertyValue<string>("title");
}