-
Notifications
You must be signed in to change notification settings - Fork 29
/
SiteSettings.cs
28 lines (24 loc) · 1.43 KB
/
SiteSettings.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
using System.Linq;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Web.Common;
using Umbraco.Extensions;
using UmbracoNineDemoSite.Core.Features.Shared.Constants;
namespace UmbracoNineDemoSite.Core.Features.Shared.Settings
{
public class SiteSettings : ISiteSettings
{
private readonly UmbracoHelper umbracoHelper;
public SiteSettings(UmbracoHelper umbracoHelper)
{
this.umbracoHelper = umbracoHelper;
}
private IPublishedContent home => this.umbracoHelper.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == ContentTypeAlias.Home);
private IPublishedContent settings => home?.Children?.FirstOrDefault(x => x.ContentType.Alias == ContentTypeAlias.SiteSettings);
public string SiteName => this.home.Name;
public string CallToActionHeader => this.settings.GetProperty(PropertyAlias.CallToActionHeader).GetValue() as string;
public string CallToActionDescription => this.settings.GetProperty(PropertyAlias.CallToActionDescription).GetValue() as string;
public IPublishedContent CallToActionUrl => this.settings.GetProperty(PropertyAlias.CallToActionUrl).GetValue() as IPublishedContent;
public string CallToActionButtonLabel => this.settings.GetProperty(PropertyAlias.CallToActionButtonLabel).GetValue() as string;
public string FooterText => this.settings.GetProperty(PropertyAlias.FooterText).GetValue() as string;
}
}