diff --git a/Lombiq.TrainingDemo/Controllers/SiteSettingsController.cs b/Lombiq.TrainingDemo/Controllers/SiteSettingsController.cs index 8c9f320..b08fa7c 100644 --- a/Lombiq.TrainingDemo/Controllers/SiteSettingsController.cs +++ b/Lombiq.TrainingDemo/Controllers/SiteSettingsController.cs @@ -35,9 +35,9 @@ public async Task SiteName() => // give it a value on the Dashboard if you want to see something here. public async Task DemoSettings() { - // As mentioned the custom settings objects are serialized into the ISite object so use the .As<>() helper to - // access it as you see below. - var messageFromSiteSettings = (await _siteService.GetSiteSettingsAsync()).As().Message; + // As mentioned the custom settings objects are serialized into the ISite object. We could use the .As<>() + // helper to access it, but Orchard Core also has the built-in GetSettingsAsync<>() shortcut to do just that. + var messageFromSiteSettings = (await _siteService.GetSettingsAsync()).Message; // But as you've seen in DemoSettings.cs our site settings are also Options so we can use it as such too: var messageFromOptions = _demoSettings.Message; diff --git a/Lombiq.TrainingDemo/Services/DemoSettingsConfiguration.cs b/Lombiq.TrainingDemo/Services/DemoSettingsConfiguration.cs index 81276f2..0221e36 100644 --- a/Lombiq.TrainingDemo/Services/DemoSettingsConfiguration.cs +++ b/Lombiq.TrainingDemo/Services/DemoSettingsConfiguration.cs @@ -38,9 +38,7 @@ public void Configure(DemoSettings options) // out what we have there related to settings and come back! // Unfortunately, no async here so we need to run this synchronously. - var settings = _siteService.GetSiteSettingsAsync() - .GetAwaiter().GetResult() - .As(); + var settings = _siteService.GetSettingsAsync().GetAwaiter().GetResult(); options.Message = settings.Message; }