public async Task <IActionResult> Status400() { var model = new HttpStatusViewModel(_defaultModelValues) { TemplateHtml = await _templateRequest.RequestTemplateHtmlAsync(), RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier }; return(View("~/_EastSussexGovUK_HttpStatus_BadRequest.cshtml", model)); }
public async Task <IActionResult> Index() { var model = new PermissionsViewModel(_defaultModelValues); try { // Do this to load the template controls. model.TemplateHtml = await _templateRequest.RequestTemplateHtmlAsync(); } catch (Exception ex) { // Catch and report exceptions - don't throw them and cause the page to fail ex.ToExceptionless().Submit(); } return(View(model)); }
/// <summary> /// Populates the properties of <see cref="BaseViewModel" /> /// </summary> /// <param name="model">The model.</param> /// <param name="content">The content.</param> /// <param name="contentExperimentSettingsService">The content experiment settings service.</param> /// <param name="expiryDate">The expiry date of the page.</param> /// <param name="inUmbracoPreviewMode">if set to <c>true</c> [in umbraco preview mode].</param> /// <param name="skinService">The skin service.</param> /// <exception cref="ArgumentNullException">model /// or /// content</exception> /// <exception cref="System.ArgumentNullException">model /// or /// content</exception> public async tasks.Task <bool> PopulateBaseViewModel(Models.BaseViewModel model, IPublishedContent content, IContentExperimentSettingsService contentExperimentSettingsService, DateTime?expiryDate, bool inUmbracoPreviewMode, ISkinToApplyService skinService = null) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } model.BreadcrumbProvider = new UmbracoBreadcrumbProvider(); if (String.IsNullOrEmpty(model.Metadata.Title)) { model.Metadata.Title = content.Name; model.Metadata.Title = new RemoveUmbracoNumericSuffixFilter().Apply(model.Metadata.Title); } model.Metadata.PageUrl = new Uri(content.UrlAbsolute()); if (String.IsNullOrEmpty(model.Metadata.Description)) { model.Metadata.Description = content.GetPropertyValue <string>("pageDescription") ?? String.Empty; } model.PageType = content.DocumentTypeAlias; model.Metadata.SystemId = content.Id.ToString(CultureInfo.InvariantCulture); model.Metadata.DateCreated = content.CreateDate.ToIso8601Date(); model.Metadata.DateModified = content.UpdateDate.ToIso8601Date(); if (expiryDate.HasValue && expiryDate != DateTime.MinValue && expiryDate != DateTime.MaxValue) { model.Metadata.DateReview = expiryDate.ToIso8601Date(); } model.IsPublicView = !inUmbracoPreviewMode && model.Metadata.PageUrl.Host.ToUpperInvariant() != "LOCALHOST"; if (contentExperimentSettingsService != null) { model.ContentExperimentPageSettings = contentExperimentSettingsService.LookupSettingsForPage(content.Id); } if (_templateRequest != null) { try { model.WebChat = await _templateRequest.RequestWebChatSettingsAsync().ConfigureAwait(false); } catch (Exception ex) { // Catch and report exceptions - don't throw them and cause the page to fail ex.ToExceptionless().Submit(); } try { model.TemplateHtml = await _templateRequest.RequestTemplateHtmlAsync().ConfigureAwait(false); } catch (Exception ex) { // Catch and report exceptions - don't throw them and cause the page to fail ex.ToExceptionless().Submit(); } } if (skinService != null) { model.SkinToApply = skinService.LookupSkinForPage(content); } // Return a value (any value) so that this async method can be run synchronously by the controller for Umbraco Forms return(true); }