-
Notifications
You must be signed in to change notification settings - Fork 29
/
HomeController.cs
43 lines (40 loc) · 1.49 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Extensions;
using UmbracoNineDemoSite.Core.Features.Shared.Components.Hero;
using UmbracoNineDemoSite.Core.Features.Shared.Extensions;
using generatedModels = UmbracoNineDemoSite.Core;
namespace UmbracoNineDemoSite.Core.Features.Home
{
public class HomeController : RenderController
{
public HomeController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor) : base(logger, compositeViewEngine, umbracoContextAccessor) { }
public IActionResult Home(ContentModel model)
{
var mbModel = model.Content as generatedModels.Home ?? new generatedModels.Home(model.Content, null);
var viewModel = new HomeViewModel()
{
Heading = mbModel.Heading,
Preamble = mbModel.Preamble,
BackgroundImage = mbModel.BackgroundImage,
CallToActionLabel = mbModel.CallToActionLabel,
CallToActionUrl = mbModel.CallToActionUrl?.Url(),
Blocks = mbModel.Blocks
};
viewModel.Hero = new HeroViewModel()
{
CallToActionUrl = viewModel.CallToActionUrl,
CallToActionLabel = viewModel.CallToActionLabel,
BackgroundImageUrl = viewModel.BackgroundImage,
Preamble = viewModel.Preamble,
Heading = viewModel.Heading
};
viewModel.MapSitePageBase(mbModel);
return View(viewModel);
}
}
}