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))); }
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); Guid.TryParse(req.Query["id"], out Guid id); var service = new HeadlessService(new HeadlessConfiguration("https://davids-placid-giraffe.s1.umbraco.io", "*****@*****.**", "&>u08E_i:r")); var content = service.GetById(id).Result; return(content != null ? (ActionResult) new OkObjectResult($"Hello, {content.Name}") : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
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)); }
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))); }
public void HeadlessServiceTest() { HeadlessMother mother = new HeadlessMother(); IThreadFactory threadFactory = new DefaultThreadFactory(); mother.ProjectRegistry.Expect(r => r.ChangeProjectStatus("Headless", ProjectStatus.CheckingTriggers)).Repeat .Any(); using (HeadlessService service = new HeadlessService( mother.ProjectRegistry, threadFactory, mother.WorkerMonitor, mother.HeadlessLogger)) { service.Start(); Thread.Sleep(TimeSpan.FromSeconds(20)); service.Stop(TimeSpan.FromSeconds(5)); } mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Headless", ProjectStatus.Sleeping)); mother.ProjectRegistry.AssertWasNotCalled(r => r.ChangeProjectStatus("ProjectPilot", ProjectStatus.Building)); mother.ProjectRegistry.AssertWasNotCalled(r => r.ChangeProjectStatus("Flubu", ProjectStatus.Building)); mother.ProjectRegistry.VerifyAllExpectations(); }
public CMSStrategy(HeadlessService headlessService) { _headlessService = headlessService; }
public HeroContainerController(UmbracoContext umbracoContext, HeadlessService headlessService) : base(umbracoContext, headlessService) { }