diff --git a/src/Employer/Employer.Web/Employer.Web.csproj b/src/Employer/Employer.Web/Employer.Web.csproj index 90ee4915c8..fe3d898ee6 100644 --- a/src/Employer/Employer.Web/Employer.Web.csproj +++ b/src/Employer/Employer.Web/Employer.Web.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp2.2 recruit-employer-web Esfa.Recruit.Employer.Web @@ -18,6 +18,7 @@ + diff --git a/src/Employer/Employer.Web/Extensions/HtmlHelperExtensions.cs b/src/Employer/Employer.Web/Extensions/HtmlHelperExtensions.cs new file mode 100644 index 0000000000..04ee193379 --- /dev/null +++ b/src/Employer/Employer.Web/Extensions/HtmlHelperExtensions.cs @@ -0,0 +1,65 @@ +using System; +using Esfa.Recruit.Employer.Web.Configuration; +using Esfa.Recruit.Employer.Web.Configuration.Routing; +using Esfa.Recruit.Shared.Web.Extensions; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.Extensions.Options; +using SFA.DAS.MA.Shared.UI.Configuration; +using SFA.DAS.MA.Shared.UI.Models; + +namespace Esfa.Recruit.Employer.Web.Extensions +{ + public static class HtmlHelperExtensions + { + public static IHeaderViewModel GetHeaderViewModel(this IHtmlHelper html, bool hideMenu = false) + { + var externalLinks = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions)) as IOptions).Value; + var authConfig = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions)) as IOptions).Value; + var requestRoot = html.ViewContext.HttpContext.Request.GetRequestUrlRoot(); + var requestPath = html.ViewContext.HttpContext.Request.Path; + var commitmentsSiteUrl = new Uri(externalLinks.CommitmentsSiteUrl); + + var headerModel = new HeaderViewModel(new HeaderConfiguration + { + EmployerCommitmentsBaseUrl = $"{commitmentsSiteUrl.Scheme}://{commitmentsSiteUrl.Host}/commitments", + EmployerFinanceBaseUrl = externalLinks.ManageApprenticeshipSiteUrl, + ManageApprenticeshipsBaseUrl = externalLinks.ManageApprenticeshipSiteUrl, + AuthenticationAuthorityUrl = authConfig.Authority, + ClientId = authConfig.ClientId, + EmployerRecruitBaseUrl = requestRoot, + SignOutUrl = new Uri($"{requestRoot}/services/logout/"), + ChangeEmailReturnUrl = new Uri($"{requestRoot}{requestPath}"), + ChangePasswordReturnUrl = new Uri($"{requestRoot}{requestPath}") + }, + new UserContext + { + User = html.ViewContext.HttpContext.User, + HashedAccountId = html.ViewContext.RouteData.Values["employerAccountId"]?.ToString() + }); + + headerModel.SelectMenu("recruitment"); + + if ((html.ViewBag.IsErrorPage is bool && html.ViewBag.IsErrorPage) || (html.ViewBag.ShowNav is bool && !html.ViewBag.ShowNav)) + { + headerModel.HideMenu(); + } + + return headerModel; + } + + public static IFooterViewModel GetFooterViewModel(this IHtmlHelper html) + { + var externalLinks = (html.ViewContext.HttpContext.RequestServices.GetService(typeof(IOptions)) as IOptions).Value; + + return new FooterViewModel(new FooterConfiguration + { + ManageApprenticeshipsBaseUrl = externalLinks.ManageApprenticeshipSiteUrl + }, + new UserContext + { + User = html.ViewContext.HttpContext.User, + HashedAccountId = html.ViewContext.RouteData.Values["employerAccountId"]?.ToString() + }); + } + } +} diff --git a/src/Employer/Employer.Web/Views/Shared/_Layout.cshtml b/src/Employer/Employer.Web/Views/Shared/_Layout.cshtml index 4965abf8c0..fb8191b45c 100644 --- a/src/Employer/Employer.Web/Views/Shared/_Layout.cshtml +++ b/src/Employer/Employer.Web/Views/Shared/_Layout.cshtml @@ -65,7 +65,7 @@ - + Skip to main content -

@ViewContext.ViewData[ViewDataKeys.PlannedOutageMessage]

@@ -86,80 +85,8 @@
- @Html.Partial("_CookieBanner") - - - -
- -
- @if (Context.User.Identity.IsAuthenticated) - { - - } + @Html.Partial("_Header", Html.GetHeaderViewModel())
@@ -174,43 +101,8 @@ @RenderBody()
+ @Html.Partial("_Footer", Html.GetFooterViewModel()) - diff --git a/src/Employer/UnitTests/UnitTests.csproj b/src/Employer/UnitTests/UnitTests.csproj index a6d4940807..4f5176c043 100644 --- a/src/Employer/UnitTests/UnitTests.csproj +++ b/src/Employer/UnitTests/UnitTests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp2.2 false Esfa.Recruit.Employer.UnitTests