public override Task <IActionResult> Index()
        {
            //get the content for the current route
            var content = UmbracoContext.GetContent();
            //map the ContentItem to a custom model called Page (which would inherit from ContentItem)
            var model = HeadlessService.MapTo <Hero>(content);

            //return the view which will be located at /Views/Page/Index.cshtml
            return(Task.FromResult((IActionResult)View(model)));
        }
        public override Task <IActionResult> Index()
        {
            // get the content for the current route
            var content = UmbracoContext.GetContent(false);

            // map the ContentItem to a custom model called Home
            var model = HeadlessService.MapTo <Home>(content);

            // return the view which will be located at
            return(Task.FromResult((IActionResult)View(model)));
        }
Beispiel #3
0
        public override async Task <IActionResult> Index()
        {
            //get the content for the current route
            var content = UmbracoContext.GetContent();

            //get all children of the container
            //var children = (await HeadlessService.Query().GetAll()).Where(x => x.ParentId.Equals(content.Id));
            var children = await HeadlessService.GetChildren <Hero>(content);

            var model = HeadlessService.MapTo <HeroContainer>(content);

            model.Children = children;//children.Select(hero => HeadlessService.MapTo<Hero>(hero));

            //return the view which will be located at /Views/Page/Index.cshtml
            return(View(model));
        }
Beispiel #4
0
        public Task <IActionResult> RenderContentItem <T>() where T : IContentBase, new()
        {
            // get the content for the current route
            var content = UmbracoContext.GetContent(false);

            if (content == null)
            {
                return(Show404());
            }

            // map the ContentItem to the requested model
            var model = HeadlessService.MapTo <T>(content);

            // return the view from the given location
            return(Task.FromResult((IActionResult)View("~/Views/DefaultUmbraco/Index.cshtml", model)));
        }