コード例 #1
0
        public async Task <IActionResult> EnterYourDetailsView(EnterYourDetailsBodyViewModel?model)
        {
            if (model != null && ModelState.IsValid)
            {
                if (await SendEmailAsync(model).ConfigureAwait(false))
                {
                    await DeleteSessionStateAsync().ConfigureAwait(false);

                    return(Redirect($"/{LocalPath}/{HomeController.ThankyouForContactingUsCanonicalName}"));
                }

                ModelState.AddModelError(string.Empty, "Unable to send message, please try again shortly");
            }

            var breadcrumbItemModel = new BreadcrumbItemModel
            {
                Route = ThisViewCanonicalName,
                Title = "Enter your details",
            };
            var viewModel = new EnterYourDetailsViewModel()
            {
                HtmlHead = new HtmlHeadViewModel
                {
                    CanonicalUrl = new Uri($"{Request.GetBaseAddress()}{LocalPath}/{ThisViewCanonicalName}", UriKind.RelativeOrAbsolute),
                    Title        = "Enter your details" + PageTitleSuffix,
                },
                Breadcrumb = BuildBreadcrumb(LocalPath, breadcrumbItemModel),
                EnterYourDetailsBodyViewModel = model,
            };

            Logger.LogInformation($"{nameof(EnterYourDetailsBody)} has returned content");

            return(this.NegotiateContentResult(viewModel));
        }
コード例 #2
0
        public async Task <IActionResult> EnterYourDetailsView()
        {
            var sessionStateModel = await GetSessionStateAsync().ConfigureAwait(false);

            var breadcrumbItemModel = new BreadcrumbItemModel
            {
                Route = ThisViewCanonicalName,
                Title = "Enter your details",
            };
            var viewModel = new EnterYourDetailsViewModel()
            {
                HtmlHead = new HtmlHeadViewModel
                {
                    CanonicalUrl = new Uri($"{Request.GetBaseAddress()}{LocalPath}/{ThisViewCanonicalName}", UriKind.RelativeOrAbsolute),
                    Title        = "Enter your details" + PageTitleSuffix,
                },
                Breadcrumb = BuildBreadcrumb(LocalPath, breadcrumbItemModel),
                EnterYourDetailsBodyViewModel = new EnterYourDetailsBodyViewModel
                {
                    SelectedCategory = sessionStateModel?.State?.Category ?? Category.None,
                    MoreDetail       = sessionStateModel?.State?.MoreDetail,
                    IsCallback       = sessionStateModel?.State?.IsCallback ?? false,
                },
            };

            Logger.LogWarning($"{nameof(EnterYourDetailsView)} has returned content");

            return(this.NegotiateContentResult(viewModel));
        }