From ba4c5b2ddc9aeef7ce3ee02fde3f50f537f1e3ce Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 27 Aug 2021 10:26:26 +0100 Subject: [PATCH 01/14] terms and condition changes --- .../Tables/User.sql | 3 +- .../Controllers/HomeController.cs | 24 +++- .../Orchestrators/EmployerTeamOrchestrator.cs | 19 ++- ...mployerTeamOrchestratorWithCallToAction.cs | 6 +- .../Orchestrators/HomeOrchestrator.cs | 22 +++- .../SFA.DAS.EmployerAccounts.Web.csproj | 4 +- .../ViewModels/AccountDashboardViewModel.cs | 19 +++ .../ViewModels/TermsAndConditionViewModel.cs | 7 ++ .../ViewModels/UserAccountsViewModel.cs | 17 +++ .../Views/EmployerTeam/Index.cshtml | 18 ++- .../Views/Home/Index.cshtml | 69 +++++++---- .../Views/Home/TermsAndConditions.cshtml | 111 ++++++++++++++++++ ...pdateTermAndConditionsAcceptedOnCommand.cs | 9 ++ ...rmAndConditionsAcceptedOnCommandHandler.cs | 21 ++++ .../EmployerAccountsConfiguration.cs | 2 + .../Data/UserRepository.cs | 16 ++- .../Interfaces/IUserRepository.cs | 1 + .../Models/UserProfile/User.cs | 1 + 18 files changed, 329 insertions(+), 40 deletions(-) create mode 100644 src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs create mode 100644 src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml create mode 100644 src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommand.cs create mode 100644 src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommandHandler.cs diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/Tables/User.sql b/src/SFA.DAS.EAS.Employer_Account.Database/Tables/User.sql index c6d97d0cc5..5cbcadfe56 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/Tables/User.sql +++ b/src/SFA.DAS.EAS.Employer_Account.Database/Tables/User.sql @@ -5,7 +5,8 @@ [Email] NVARCHAR(255) NOT NULL UNIQUE, [FirstName] NVARCHAR(MAX) NULL, [LastName] NVARCHAR(MAX) NULL, - [CorrelationId] NVARCHAR(255) NULL + [CorrelationId] NVARCHAR(255) NULL, + [TermAndConditionsAcceptedOn] DATETIME NULL ) GO diff --git a/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs b/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs index e70b90eefb..3b8c6e4d38 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs @@ -60,7 +60,7 @@ public async Task Index() { return Redirect(ConfigurationFactory.Current.Get().AccountActivationUrl); } - + var userRef = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); var email = OwinWrapper.GetClaimValue(ControllerConstants.EmailClaimKeyName); var firstName = OwinWrapper.GetClaimValue(DasClaimTypes.GivenName); @@ -68,7 +68,7 @@ public async Task Index() await _homeOrchestrator.SaveUpdatedIdentityAttributes(userRef, email, firstName, lastName); - accounts = await _homeOrchestrator.GetUserAccounts(userId); + accounts = await _homeOrchestrator.GetUserAccounts(userId, _configuration.LastTermsAndConditionsUpdate); } else { @@ -110,6 +110,26 @@ public async Task Index() return RedirectToAction(ControllerConstants.GetApprenticeshipFundingActionName, ControllerConstants.EmployerAccountControllerName); } + + [HttpGet] + [DasAuthorize] + [Route("termsAndConditions")] + public ActionResult TermsAndConditions(string returnUrl) + { + var termsAndConditionViewModel = new TermsAndConditionViewModel { ReturnUrl = returnUrl }; + return View(termsAndConditionViewModel); + } + + [HttpPost] + [DasAuthorize] + [Route("termsAndConditions")] + public async Task TermsAndConditions(TermsAndConditionViewModel termsAndConditionViewModel) + { + var userRef = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); + await _homeOrchestrator.UpdateTermAndConditionsAcceptedOn(userRef); + return RedirectToAction(nameof(Index)); + } + [DasAuthorize] [Route("SaveAndSearch")] public async Task SaveAndSearch(string returnUrl) diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs index dc8e54771e..f743f08913 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs @@ -9,6 +9,7 @@ using SFA.DAS.EmployerAccounts.Commands.RemoveTeamMember; using SFA.DAS.EmployerAccounts.Commands.ResendInvitation; using SFA.DAS.EmployerAccounts.Commands.UpdateShowWizard; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models; using SFA.DAS.EmployerAccounts.Models.Account; @@ -24,6 +25,7 @@ using SFA.DAS.EmployerAccounts.Queries.GetMember; using SFA.DAS.EmployerAccounts.Queries.GetTeamUser; using SFA.DAS.EmployerAccounts.Queries.GetUser; +using SFA.DAS.EmployerAccounts.Queries.GetUserByRef; using SFA.DAS.EmployerAccounts.Web.ViewModels; using SFA.DAS.Validation; using System; @@ -41,17 +43,20 @@ public class EmployerTeamOrchestrator : UserVerificationOrchestratorBase private readonly ICurrentDateTime _currentDateTime; private readonly IAccountApiClient _accountApiClient; private readonly IMapper _mapper; + private readonly EmployerAccountsConfiguration _configuration; public EmployerTeamOrchestrator(IMediator mediator, ICurrentDateTime currentDateTime, IAccountApiClient accountApiClient, - IMapper mapper) + IMapper mapper, + EmployerAccountsConfiguration configuration) : base(mediator) { _mediator = mediator; _currentDateTime = currentDateTime; _accountApiClient = accountApiClient; _mapper = mapper; + _configuration = configuration; } //Needed for tests protected EmployerTeamOrchestrator() @@ -179,7 +184,12 @@ public virtual async Task> GetAc ExternalUserId = externalUserId }); - await Task.WhenAll(apiGetAccountTask, accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask).ConfigureAwait(false); + var userQueryResponseTask = _mediator.SendAsync(new GetUserByRefQuery + { + UserRef = externalUserId + }); + + await Task.WhenAll(apiGetAccountTask, accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask, userQueryResponseTask).ConfigureAwait(false); var accountResponse = accountResponseTask.Result; var userRoleResponse = userRoleResponseTask.Result; @@ -187,6 +197,7 @@ public virtual async Task> GetAc var accountStatsResponse = accountStatsResponseTask.Result; var agreementsResponse = agreementsResponseTask.Result; var accountDetailViewModel = apiGetAccountTask.Result; + var userQueryResponse = userQueryResponseTask.Result; var apprenticeshipEmployerType = (ApprenticeshipEmployerType)Enum.Parse(typeof(ApprenticeshipEmployerType), accountDetailViewModel.ApprenticeshipEmployerType, true); @@ -219,7 +230,9 @@ public virtual async Task> GetAc SignedAgreementCount = agreementsResponse.EmployerAgreements.Count(x => x.HasSignedAgreement), PendingAgreements = pendingAgreements, ApprenticeshipEmployerType = apprenticeshipEmployerType, - AgreementInfo = _mapper.Map(accountDetailViewModel) + AgreementInfo = _mapper.Map(accountDetailViewModel), + TermAndConditionsAcceptedOn = userQueryResponse.User.TermAndConditionsAcceptedOn, + LastTermsAndConditionsUpdate = _configuration.LastTermsAndConditionsUpdate }; //note: ApprenticeshipEmployerType is already returned by GetEmployerAccountHashedQuery, but we need to transition to calling the api instead. diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestratorWithCallToAction.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestratorWithCallToAction.cs index c6cf45840f..1db4c75d54 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestratorWithCallToAction.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestratorWithCallToAction.cs @@ -19,6 +19,7 @@ using SFA.DAS.Common.Domain.Types; using SFA.DAS.EmployerAccounts.Web.Models; using SFA.DAS.NLog.Logger; +using SFA.DAS.EmployerAccounts.Configuration; namespace SFA.DAS.EmployerAccounts.Web.Orchestrators { @@ -38,8 +39,9 @@ public EmployerTeamOrchestratorWithCallToAction( IAccountApiClient accountApiClient, IMapper mapper, ICookieStorageService accountContext, - ILog logger) - : base(mediator, currentDateTime, accountApiClient, mapper) + ILog logger, + EmployerAccountsConfiguration configuration) + : base(mediator, currentDateTime, accountApiClient, mapper, configuration) { _employerTeamOrchestrator = employerTeamOrchestrator; _accountContext = accountContext; diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/HomeOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/HomeOrchestrator.cs index e68742cf38..ba4f832bdb 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/HomeOrchestrator.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/HomeOrchestrator.cs @@ -9,6 +9,8 @@ using SFA.DAS.EmployerAccounts.Queries.GetUserAccounts; using SFA.DAS.EmployerAccounts.Queries.GetUserInvitations; using SFA.DAS.EmployerAccounts.Queries.GetUsers; +using SFA.DAS.EmployerAccounts.Queries.GetUser; +using SFA.DAS.EmployerAccounts.Queries.GetUserByRef; namespace SFA.DAS.EmployerAccounts.Web.Orchestrators { @@ -44,7 +46,7 @@ public virtual async Task GetUsers() }; } - public virtual async Task> GetUserAccounts(string userId) + public virtual async Task> GetUserAccounts(string userId, DateTime? LastTermsAndConditionsUpdate = null) { var getUserAccountsQueryResponse = await _mediator.SendAsync(new GetUserAccountsQuery { @@ -54,12 +56,18 @@ public virtual async Task> GetUserAc { UserId = userId }); + var getUserQueryResponse = await _mediator.SendAsync(new GetUserByRefQuery + { + UserRef = userId + }); return new OrchestratorResponse { Data = new UserAccountsViewModel { Accounts = getUserAccountsQueryResponse.Accounts, - Invitations = getUserInvitationsResponse.NumberOfInvites + Invitations = getUserInvitationsResponse.NumberOfInvites, + TermAndConditionsAcceptedOn = getUserQueryResponse.User.TermAndConditionsAcceptedOn, + LastTermsAndConditionsUpdate = LastTermsAndConditionsUpdate } }; } @@ -108,6 +116,14 @@ await _mediator.SendAsync(new UpsertRegisteredUserCommand FirstName = firstName, CorrelationId = correlationId }); - } + } + + public virtual async Task UpdateTermAndConditionsAcceptedOn(string userRef) + { + await _mediator.SendAsync(new UpdateTermAndConditionsAcceptedOnCommand + { + UserRef = userRef + }); + } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj b/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj index 4e78932832..63de102b47 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj +++ b/src/SFA.DAS.EmployerAccounts.Web/SFA.DAS.EmployerAccounts.Web.csproj @@ -255,6 +255,7 @@ + @@ -873,6 +874,7 @@ + @@ -942,4 +944,4 @@ --> - + \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/AccountDashboardViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/AccountDashboardViewModel.cs index 5beba88edd..c79b08136f 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/AccountDashboardViewModel.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/AccountDashboardViewModel.cs @@ -2,6 +2,7 @@ using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models; using SFA.DAS.EmployerAccounts.Models.Account; +using System; using System.Collections.Generic; namespace SFA.DAS.EmployerAccounts.Web.ViewModels @@ -29,5 +30,23 @@ public class AccountDashboardViewModel : IAccountIdentifier public ApprenticeshipEmployerType ApprenticeshipEmployerType { get; set; } public CallToActionViewModel CallToActionViewModel { get; set; } public bool HideTasksBar { get; set; } + public DateTime? TermAndConditionsAcceptedOn { get; set; } + public DateTime? LastTermsAndConditionsUpdate { get; set; } + public bool ShowTermsAndConditionBanner + { + get + { + if (LastTermsAndConditionsUpdate.HasValue) + { + if (!TermAndConditionsAcceptedOn.HasValue || + (TermAndConditionsAcceptedOn.Value < LastTermsAndConditionsUpdate.Value)) + { + return true; + } + } + + return false; + } + } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs new file mode 100644 index 0000000000..ae87f869aa --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs @@ -0,0 +1,7 @@ +namespace SFA.DAS.EmployerAccounts.Web.ViewModels +{ + public class TermsAndConditionViewModel + { + public string ReturnUrl { get; set; } + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/UserAccountsViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/UserAccountsViewModel.cs index c31add0a8e..8dea3a74e9 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/UserAccountsViewModel.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/UserAccountsViewModel.cs @@ -1,4 +1,5 @@ using SFA.DAS.EmployerAccounts.Models.Account; +using System; namespace SFA.DAS.EmployerAccounts.Web.ViewModels { @@ -8,5 +9,21 @@ public class UserAccountsViewModel public int Invitations; public FlashMessageViewModel FlashMessage; public string ErrorMessage; + public DateTime? TermAndConditionsAcceptedOn { get; set; } + public DateTime? LastTermsAndConditionsUpdate { get; set; } + public bool ShowTermsAndConditionBanner { get + { + if (LastTermsAndConditionsUpdate.HasValue) + { + if (!TermAndConditionsAcceptedOn.HasValue || + (TermAndConditionsAcceptedOn.Value < LastTermsAndConditionsUpdate.Value)) + { + return true; + } + } + + return false; + } + } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml index 503b64d60e..4195fa8aef 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml @@ -21,6 +21,22 @@ } } + +@if (Model.Data.ShowTermsAndConditionBanner) +{ +
+
+

+ Action required +

+
+
+

+ We've updated our terms of use. By continuing to use this service you are accepting the updated terms. +

+
+
+}

Account ID: @Model.Data.Account.PublicHashedId

@@ -103,7 +119,7 @@ else } - @if (Model.Data.ApprenticeshipEmployerType == ApprenticeshipEmployerType.Levy + @if (Model.Data.ApprenticeshipEmployerType == ApprenticeshipEmployerType.Levy && Html.IsAuthorized("EmployerFeature.TransfersMatching")) {
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml index 7855dd81f7..d83c649783 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml @@ -12,23 +12,40 @@
+ + @if (Model.Data.ShowTermsAndConditionBanner) + { +
+
+

+ Action required +

+
+
+

+ We've updated our terms of use. By continuing to use this service you are accepting the updated terms. +

+
+
+ } + @if (Model.Data.Accounts.AccountList.Count != 0) { -

Your accounts

+

Your accounts

-

Select an account or add a new one.

+

Select an account or add a new one.

- - - - - - - - - - - @foreach (var account in Model.Data.Accounts.AccountList) +
Table of accounts with permissions
Account nameWhat you can doSelect account
+ + + + + + + + + + @foreach (var account in Model.Data.Accounts.AccountList) { } - -
Table of accounts with permissions
Account nameWhat you can doSelect account
@@ -45,31 +62,31 @@ Open @account.Name account homepage
+ + -

- Add new account -

+

+ Add new account +

} @if (Model.Data.Accounts.AccountList.Count != 0 && Model.Data.Invitations > 0) { -

Invitations

+

Invitations

-

- You have @Model.Data.Invitations pending invitation@(Model.Data.Invitations == 1 ? "" : "s") to employer accounts. -

+

+ You have @Model.Data.Invitations pending invitation@(Model.Data.Invitations == 1 ? "" : "s") to employer accounts. +

-

- View Invitations -

+

+ View Invitations +

}
\ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml new file mode 100644 index 0000000000..d08bbf8ccd --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml @@ -0,0 +1,111 @@ +@{ ViewBag.PageID = "page-terms-and-condition"; } +@{ ViewBag.Section = "home"; } +@{ ViewBag.Title = "Term and Conditions"; } +@*@{ ViewBag.HideNav = true; } +@{ ViewBag.HideAccounts = "true"; }*@ +@*@{ ViewBag.GaData.Vpv = "/page-auth-homepage"; }*@ +@{Layout = "~/Views/Shared/_Layout_CDN.cshtml"; } +
+
+

Terms of use

+ +

+ To use this service you agree to:  +

+ +

New for this release

+ + +
    +
  • + Use only a legitimate email address that you or people in your organisation has access to +
  • +
  • + Keep your sign in details secure and do not share them with third parties  +
  • +
  • + If you are a commercial organisation as defined in section 54 of the Modern Slavery Act 2015, adhere to the annual reporting requirements +
  • +
  • + Not provide feedback on a training provider when you are an employer provider +
  • +
  • + Be an active and trading business at the point of creating an apprenticeship service account +
  • +
  • + Only add apprentices that are linked to the PAYE scheme registered in your employer account +
  • +
  • + Comply at all times with the Apprenticeship Agreement for Employers and Apprenticeship Funding Rules +
  • +
+ + +

+ Existing terms + +

+ +
    +
  • + Sign out at the end of each session  +
  • +
  • + Input truthful and accurate information   +
  • +
  • + Adhere to the Computer Misuse Act 1990 +
  • + +
  • + Not use discriminatory wording set out in the Equality Act 2010 +
  • +
  • + Make sure the published rates of pay comply with the National minimum wage guidelines and are not misleading to candidates   +
  • +
  • + Adhere to all relevant UK employment laws  +
  • + +
  • + Your apprenticeship adverts being publicly accessible, including the possibility of partner websites displaying them   +
  • +
  • + Comply with the government safeguarding policies for children  and vulnerable adults +
  • + +
+

+ When you sign up for an apprenticeship service account we may need to verify and validate your company.  You may not be granted an account if you fail the checks conducted by ESFA. +

+

+ Your contact details and information associated with your account will be collected and used for the support and administration of your account.   +

+

+ We will not:  +

+

    +
  • + Use or disclose this information for other purposes (except where we’re legally required to do so)  +
  • +
  • + Use your details for any marketing purposes or for any reason unrelated to the use of your account   +
  • +
+

+ We may update these terms and conditions at any time without notice. You’ll agree to any changes if you continue to use this service after the terms and conditions have been updated.   +

+
+ +
+
+

+ Cancel +

+ +

+
+
+ diff --git a/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommand.cs b/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommand.cs new file mode 100644 index 0000000000..2a34e8c256 --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommand.cs @@ -0,0 +1,9 @@ +using MediatR; + +namespace SFA.DAS.EmployerAccounts.Commands.UpsertRegisteredUser +{ + public class UpdateTermAndConditionsAcceptedOnCommand : IAsyncRequest + { + public string UserRef { get; set; } + } +} diff --git a/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommandHandler.cs b/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommandHandler.cs new file mode 100644 index 0000000000..e2bb19af41 --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts/Commands/UpdateTermAndConditionsAcceptedOn/UpdateTermAndConditionsAcceptedOnCommandHandler.cs @@ -0,0 +1,21 @@ +using MediatR; +using System.Threading.Tasks; +using SFA.DAS.EmployerAccounts.Interfaces; + +namespace SFA.DAS.EmployerAccounts.Commands.UpsertRegisteredUser +{ + public class UpdateTermAndConditionsAcceptedOnCommandHandler : AsyncRequestHandler + { + private readonly IUserRepository _userRepository; + public UpdateTermAndConditionsAcceptedOnCommandHandler( + IUserRepository userRepository) + { + _userRepository = userRepository; + } + + protected override async Task HandleCore(UpdateTermAndConditionsAcceptedOnCommand message) + { + await _userRepository.UpdateTermAndConditionsAcceptedOn(message.UserRef); + } + } +} diff --git a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs index 455ed63ac2..490dff252b 100644 --- a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs +++ b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs @@ -2,6 +2,7 @@ using SFA.DAS.EAS.Account.Api.Client; using SFA.DAS.Hmrc.Configuration; using SFA.DAS.Messaging.AzureServiceBus.StructureMap; +using System; namespace SFA.DAS.EmployerAccounts.Configuration { @@ -54,5 +55,6 @@ public class EmployerAccountsConfiguration : ITopicMessagePublisherConfiguration public string ApplicationId { get; set; } public int DefaultCacheExpirationInMinutes { get; set; } public string SupportConsoleUsers { get; set; } + public DateTime? LastTermsAndConditionsUpdate { get; set; } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts/Data/UserRepository.cs b/src/SFA.DAS.EmployerAccounts/Data/UserRepository.cs index 1f5e16801e..8ec2bac0f0 100644 --- a/src/SFA.DAS.EmployerAccounts/Data/UserRepository.cs +++ b/src/SFA.DAS.EmployerAccounts/Data/UserRepository.cs @@ -40,7 +40,7 @@ public async Task GetUserByRef(string id) parameters.Add("@userRef", new Guid(id), DbType.Guid); var result = await _db.Value.Database.Connection.QueryAsync( - sql: "SELECT Id, CONVERT(varchar(64), UserRef) as UserRef, Email, FirstName, LastName, CorrelationId FROM [employer_account].[User] WHERE UserRef = @userRef", + sql: "SELECT Id, CONVERT(varchar(64), UserRef) as UserRef, Email, FirstName, LastName, CorrelationId,TermAndConditionsAcceptedOn FROM [employer_account].[User] WHERE UserRef = @userRef", param: parameters, transaction: _db.Value.Database.CurrentTransaction.UnderlyingTransaction, commandType: CommandType.Text); @@ -96,6 +96,20 @@ public Task Update(User user) commandType: CommandType.Text); } + public Task UpdateTermAndConditionsAcceptedOn(string userRef) + { + var parameters = new DynamicParameters(); + + parameters.Add("@termAndConditionsAcceptedOn", DateTime.UtcNow, DbType.DateTime); + parameters.Add("@userRef", new Guid(userRef), DbType.Guid); + + return _db.Value.Database.Connection.ExecuteAsync( + sql: "UPDATE [employer_account].[User] set TermAndConditionsAcceptedOn = @termAndConditionsAcceptedOn where UserRef = @userRef", + param: parameters, + transaction: _db.Value.Database.CurrentTransaction.UnderlyingTransaction, + commandType: CommandType.Text); + } + public Task Upsert(User user) { return WithConnection(c => diff --git a/src/SFA.DAS.EmployerAccounts/Interfaces/IUserRepository.cs b/src/SFA.DAS.EmployerAccounts/Interfaces/IUserRepository.cs index c09986a07d..9bcf9ffcf5 100644 --- a/src/SFA.DAS.EmployerAccounts/Interfaces/IUserRepository.cs +++ b/src/SFA.DAS.EmployerAccounts/Interfaces/IUserRepository.cs @@ -17,5 +17,6 @@ public interface IUserRepository Task GetAllUsers(); Task UpdateAornPayeQueryAttempt(string userRef, bool success); Task> GetAornPayeQueryAttempts(string userRef); + Task UpdateTermAndConditionsAcceptedOn(string userRef); } } diff --git a/src/SFA.DAS.EmployerAccounts/Models/UserProfile/User.cs b/src/SFA.DAS.EmployerAccounts/Models/UserProfile/User.cs index 08a174eab7..6194ef7e82 100644 --- a/src/SFA.DAS.EmployerAccounts/Models/UserProfile/User.cs +++ b/src/SFA.DAS.EmployerAccounts/Models/UserProfile/User.cs @@ -25,6 +25,7 @@ public string UserRef public virtual string FirstName { get; set; } public virtual string LastName { get; set; } public virtual string CorrelationId { get; set; } + public virtual DateTime? TermAndConditionsAcceptedOn { get; set; } public string FullName => $"{FirstName} {LastName}"; public virtual ICollection Memberships { get; protected set; } = new List(); public virtual ICollection UserAccountSettings { get; protected set; } = new List(); From b1eddd0919ade442549f81b37bf82cba68278121 Mon Sep 17 00:00:00 2001 From: James King Date: Fri, 27 Aug 2021 10:50:47 +0100 Subject: [PATCH 02/14] Updated gulp scripts --- src/SFA.DAS.EmployerAccounts.Web/gulpfile.js | 6 +++--- src/SFA.DAS.EmployerAccounts.Web/package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/gulpfile.js b/src/SFA.DAS.EmployerAccounts.Web/gulpfile.js index 8fcbcb4839..aee4458297 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/gulpfile.js +++ b/src/SFA.DAS.EmployerAccounts.Web/gulpfile.js @@ -16,11 +16,11 @@ sassOptions = { includePaths: [ 'src/govuk_template/assets/stylesheets', 'src/govuk_frontend_toolkit/stylesheets' - ] + ], }; gulp.task('watch', () => { - gulp.watch(input, ['sass']) + gulp.watch(input, gulp.series('sass')) .on('change', (event) => { console.log(`File ${event.path} was ${event.type}, running tasks...`); }); @@ -32,4 +32,4 @@ gulp.task('sass', () => gulp .pipe(gulp.dest(output))); -gulp.task('default', ['sass', 'watch']); \ No newline at end of file +gulp.task('default', gulp.series('sass', 'watch')); \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/package.json b/src/SFA.DAS.EmployerAccounts.Web/package.json index 34f0b6bcb3..b92a51fa50 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/package.json +++ b/src/SFA.DAS.EmployerAccounts.Web/package.json @@ -1,7 +1,7 @@ { "devDependencies": { - "gulp": "^3.9.1", - "gulp-sass": "^3.1.0", + "gulp": "^4.0.2", + "gulp-sass": "^4.1.1", "gulp-clean-css": "^3.10.0", "gulp-concat": "^2.6.1", "gulp-rename": "^1.4.0", From 2f9fe700eba7a8cd038b0526b0c10d2bcfdcd58a Mon Sep 17 00:00:00 2001 From: James King Date: Fri, 27 Aug 2021 10:51:19 +0100 Subject: [PATCH 03/14] govuk notifocation banner styles --- .../dist/css/screen-ie6.css | 60 ++++++++++++++ .../dist/css/screen-ie7.css | 60 ++++++++++++++ .../dist/css/screen-ie8.css | 60 ++++++++++++++ .../dist/css/screen.css | 70 ++++++++++++++++ .../src/sass/_notifications.scss | 82 ++++++++++++++++++- 5 files changed, 331 insertions(+), 1 deletion(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie6.css b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie6.css index dacc7c11cb..4a90931c1b 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie6.css +++ b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie6.css @@ -2229,6 +2229,66 @@ a#link-settings { padding-left: 0.5em; padding-right: 0.5em; } +.govuk-notification-banner { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 400; + font-size: 16px; + line-height: 1.25; + margin-bottom: 30px; + border: 5px solid #1d70b8; + background-color: #1d70b8; + margin-bottom: 50px; } + +.govuk-notification-banner--dashboard { + margin: 30px 0; } + +.govuk-notification-banner__header { + padding: 2px 15px 5px; + border-bottom: 1px solid transparent; + padding: 2px 20px 5px; } + +.govuk-notification-banner__title { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 16px; + line-height: 1.25; + margin: 0; + padding: 0; + color: #fff; + font-size: 19px; + line-height: 1.35; } + +.govuk-notification-banner__content { + color: #0b0c0c; + padding: 15px; + background-color: #fff; + padding: 20px; } + +.govuk-notification-banner__content > :last-child { + margin-bottom: 0; } + +.govuk-notification-banner__heading { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 18px; + line-height: 1.1; + margin: 0 0 15px 0; + padding: 0; + font-size: 24px; + line-height: 1.25; } + +.govuk-notification-banner__link { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: underline; } + .previous-next-navigation { margin: 40px -3px; padding: 3px; diff --git a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie7.css b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie7.css index 728e8d4aeb..eed8b7a971 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie7.css +++ b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie7.css @@ -2225,6 +2225,66 @@ a#link-settings { padding-left: 0.5em; padding-right: 0.5em; } +.govuk-notification-banner { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 400; + font-size: 16px; + line-height: 1.25; + margin-bottom: 30px; + border: 5px solid #1d70b8; + background-color: #1d70b8; + margin-bottom: 50px; } + +.govuk-notification-banner--dashboard { + margin: 30px 0; } + +.govuk-notification-banner__header { + padding: 2px 15px 5px; + border-bottom: 1px solid transparent; + padding: 2px 20px 5px; } + +.govuk-notification-banner__title { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 16px; + line-height: 1.25; + margin: 0; + padding: 0; + color: #fff; + font-size: 19px; + line-height: 1.35; } + +.govuk-notification-banner__content { + color: #0b0c0c; + padding: 15px; + background-color: #fff; + padding: 20px; } + +.govuk-notification-banner__content > :last-child { + margin-bottom: 0; } + +.govuk-notification-banner__heading { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 18px; + line-height: 1.1; + margin: 0 0 15px 0; + padding: 0; + font-size: 24px; + line-height: 1.25; } + +.govuk-notification-banner__link { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: underline; } + .previous-next-navigation { margin: 40px -3px; padding: 3px; diff --git a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie8.css b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie8.css index b18b512221..c9fc52726b 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie8.css +++ b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie8.css @@ -2195,6 +2195,66 @@ a#link-settings { padding-left: 0.5em; padding-right: 0.5em; } +.govuk-notification-banner { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 400; + font-size: 16px; + line-height: 1.25; + margin-bottom: 30px; + border: 5px solid #1d70b8; + background-color: #1d70b8; + margin-bottom: 50px; } + +.govuk-notification-banner--dashboard { + margin: 30px 0; } + +.govuk-notification-banner__header { + padding: 2px 15px 5px; + border-bottom: 1px solid transparent; + padding: 2px 20px 5px; } + +.govuk-notification-banner__title { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 16px; + line-height: 1.25; + margin: 0; + padding: 0; + color: #fff; + font-size: 19px; + line-height: 1.35; } + +.govuk-notification-banner__content { + color: #0b0c0c; + padding: 15px; + background-color: #fff; + padding: 20px; } + +.govuk-notification-banner__content > :last-child { + margin-bottom: 0; } + +.govuk-notification-banner__heading { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 18px; + line-height: 1.1; + margin: 0 0 15px 0; + padding: 0; + font-size: 24px; + line-height: 1.25; } + +.govuk-notification-banner__link { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: underline; } + .previous-next-navigation { margin: 40px -3px; padding: 3px; diff --git a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen.css b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen.css index 4931708177..186d6ab77a 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen.css +++ b/src/SFA.DAS.EmployerAccounts.Web/dist/css/screen.css @@ -2433,6 +2433,76 @@ a#link-settings { padding-left: 0.5em; padding-right: 0.5em; } +.govuk-notification-banner { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 400; + font-size: 16px; + line-height: 1.25; + margin-bottom: 30px; + border: 5px solid #1d70b8; + background-color: #1d70b8; } + @media (min-width: 641px) { + .govuk-notification-banner { + margin-bottom: 50px; } } + +.govuk-notification-banner--dashboard { + margin: 30px 0; } + +.govuk-notification-banner__header { + padding: 2px 15px 5px; + border-bottom: 1px solid transparent; } + @media (min-width: 641px) { + .govuk-notification-banner__header { + padding: 2px 20px 5px; } } + +.govuk-notification-banner__title { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 16px; + line-height: 1.25; + margin: 0; + padding: 0; + color: #fff; } + @media (min-width: 641px) { + .govuk-notification-banner__title { + font-size: 19px; + line-height: 1.35; } } + +.govuk-notification-banner__content { + color: #0b0c0c; + padding: 15px; + background-color: #fff; } + @media (min-width: 641px) { + .govuk-notification-banner__content { + padding: 20px; } } + +.govuk-notification-banner__content > :last-child { + margin-bottom: 0; } + +.govuk-notification-banner__heading { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 18px; + line-height: 1.1; + margin: 0 0 15px 0; + padding: 0; } + @media (min-width: 641px) { + .govuk-notification-banner__heading { + font-size: 24px; + line-height: 1.25; } } + +.govuk-notification-banner__link { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: underline; } + .previous-next-navigation { margin: 40px -3px; padding: 3px; diff --git a/src/SFA.DAS.EmployerAccounts.Web/src/sass/_notifications.scss b/src/SFA.DAS.EmployerAccounts.Web/src/sass/_notifications.scss index dd83792e0f..f172676de3 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/src/sass/_notifications.scss +++ b/src/SFA.DAS.EmployerAccounts.Web/src/sass/_notifications.scss @@ -139,4 +139,84 @@ $warning-colour: $orange; padding-left:0.5em; padding-right:0.5em; } - \ No newline at end of file + + + + +.govuk-notification-banner { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 400; + font-size: 16px; + line-height: 1.25; + margin-bottom: 30px; + border: 5px solid #1d70b8; + background-color: #1d70b8; + @include media (tablet) { + margin-bottom: 50px; + } +} + +.govuk-notification-banner--dashboard { + margin: 30px 0; +} + +.govuk-notification-banner__header { + padding: 2px 15px 5px; + border-bottom: 1px solid transparent; + @include media (tablet) { + padding: 2px 20px 5px; + } +} + +.govuk-notification-banner__title { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 16px; + line-height: 1.25; + margin: 0; + padding: 0; + color: #fff; + @include media (tablet) { + font-size: 19px; + line-height: 1.35; + } +} + +.govuk-notification-banner__content { + color: #0b0c0c; + padding: 15px; + background-color: #fff; + @include media (tablet) { + padding: 20px; + } +} + +.govuk-notification-banner__content>:last-child { + margin-bottom: 0; +} + +.govuk-notification-banner__heading { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-weight: 700; + font-size: 18px; + line-height: 1.1; + margin: 0 0 15px 0; + padding: 0; + @include media (tablet) { + font-size: 24px; + line-height: 1.25; + } +} + +.govuk-notification-banner__link { + font-family: "nta", Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: underline; +} \ No newline at end of file From 9bf30ecd7c863b1f9a3169a642eb80d78f0c8de5 Mon Sep 17 00:00:00 2001 From: James King Date: Fri, 27 Aug 2021 10:51:36 +0100 Subject: [PATCH 04/14] Additional class for margins --- .../Views/EmployerTeam/Index.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml index 4195fa8aef..3d5300a11b 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml @@ -24,7 +24,7 @@ @if (Model.Data.ShowTermsAndConditionBanner) { -
+

Action required From 4f9bfbc810f470a1d522438de9bd426958014165 Mon Sep 17 00:00:00 2001 From: James King Date: Fri, 27 Aug 2021 10:56:35 +0100 Subject: [PATCH 05/14] Additional class to signin link so it can be seen --- .../Views/Home/ServiceStartPage.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/ServiceStartPage.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/ServiceStartPage.cshtml index 985430dc57..77c5a5108e 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/ServiceStartPage.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/ServiceStartPage.cshtml @@ -16,7 +16,7 @@ @ViewBag.Title

- You need to create or sign in to an apprenticeship account, then you'll be able to get funding to pay for apprenticeship training and assessment costs. + You need to create or sign in to an apprenticeship account, then you'll be able to get funding to pay for apprenticeship training and assessment costs.

You’ll use your account to: From e580b791b52c2f793714d62f04ea3cc6888b8f4f Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 27 Aug 2021 12:03:20 +0100 Subject: [PATCH 06/14] Unit test fix --- .../WhenIViewTermsAndCondition.cs | 62 +++++++++++++++++++ .../WhenIViewTheHomePage.cs | 9 +-- .../WhenGettingAccount.cs | 3 +- .../WhenIChangeATeamMemberRole.cs | 3 +- .../WhenIGetATeamMembersDetails.cs | 3 +- .../WhenIGetMyTeamMembers.cs | 3 +- .../WhenIInviteATeamMember.cs | 3 +- .../WhenIRemoveATeamMember.cs | 3 +- .../WhenGettingAccount.cs | 4 +- .../Controllers/HomeController.cs | 9 ++- .../ViewModels/TermsAndConditionViewModel.cs | 1 + .../Views/EmployerTeam/Index.cshtml | 2 +- .../Views/Home/Index.cshtml | 2 +- .../Views/Home/TermsAndConditions.cshtml | 28 ++++++--- 14 files changed, 112 insertions(+), 23 deletions(-) create mode 100644 src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs new file mode 100644 index 0000000000..d98b4e96a4 --- /dev/null +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs @@ -0,0 +1,62 @@ +using System; +using System.Threading.Tasks; +using System.Web.Mvc; +using Moq; +using NUnit.Framework; +using SFA.DAS.EmployerAccounts.Configuration; +using SFA.DAS.EmployerAccounts.Interfaces; +using SFA.DAS.EmployerAccounts.Web.Controllers; +using SFA.DAS.EmployerAccounts.Web.Orchestrators; +using SFA.DAS.EmployerAccounts.Web.ViewModels; +using SFA.DAS.EmployerUsers.WebClientComponents; +using SFA.DAS.Authentication; +using SFA.DAS.EmployerAccounts.Web.Models; +using SFA.DAS.NLog.Logger; + +namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.HomeControllerTests +{ + public class WhenIViewTermsAndCondition : ControllerTestBase + { + private Mock _owinWrapper; + private Mock _homeOrchestrator; + private EmployerAccountsConfiguration _configuration; + private Mock _userViewTestingService; + private HomeController _homeController; + private Mock> _flashMessage; + + [SetUp] + public void Arrage() + { + base.Arrange(); + + _owinWrapper = new Mock(); + _homeOrchestrator = new Mock(); + _userViewTestingService = new Mock(); + _flashMessage = new Mock>(); + _configuration = new EmployerAccountsConfiguration(); + + _homeController = new HomeController( + _owinWrapper.Object, + _homeOrchestrator.Object, + _configuration, + _userViewTestingService.Object, + _flashMessage.Object, + Mock.Of>(), + Mock.Of()) + { + ControllerContext = _controllerContext.Object + }; + } + + [Test] + public void ThenTheViewIsReturned() + { + //Act + var actual = _homeController.TermsAndConditions("returnUrl", "hashedId"); + + //Assert + Assert.IsNotNull(actual); + Assert.IsAssignableFrom(actual); + } + } +} diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs index 262df61b55..59d18d773b 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs @@ -16,6 +16,7 @@ using SFA.DAS.Authentication; using SFA.DAS.EmployerAccounts.Web.Models; using SFA.DAS.NLog.Logger; +using System; namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.HomeControllerTests { @@ -41,7 +42,7 @@ public void Arrange() _homeOrchestrator = new Mock(); _homeOrchestrator.Setup(x => x.GetUsers()).ReturnsAsync(new SignInUserViewModel()); - _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId)).ReturnsAsync( + _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId, null)).ReturnsAsync( new OrchestratorResponse { Data = new UserAccountsViewModel @@ -92,7 +93,7 @@ public async Task ThenTheAccountsAreNotReturnedWhenYouAreNotAuthenticated() await _homeController.Index(); //Assert - _homeOrchestrator.Verify(x => x.GetUserAccounts(It.IsAny()), Times.Never); + _homeOrchestrator.Verify(x => x.GetUserAccounts(It.IsAny(), It.IsAny()), Times.Never); } [Test] @@ -127,7 +128,7 @@ public async Task ThenTheAccountsAreReturnedForThatUserWhenAuthenticated() await _homeController.Index(); //Assert - _homeOrchestrator.Verify(x => x.GetUserAccounts(ExpectedUserId), Times.Once); + _homeOrchestrator.Verify(x => x.GetUserAccounts(ExpectedUserId, It.IsAny()), Times.Once); } [Test] @@ -199,7 +200,7 @@ public async Task ThenIfIHaveMoreThanOneAccountIAmRedirectedToTheAccountsIndexPa { //Arrange _owinWrapper.Setup(x => x.GetClaimValue("sub")).Returns(ExpectedUserId); - _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId)).ReturnsAsync( + _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId, It.IsAny())).ReturnsAsync( new OrchestratorResponse { Data = new UserAccountsViewModel diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs index e906d648a9..c32d1dc551 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs @@ -29,6 +29,7 @@ using SFA.DAS.EmployerAccounts.Web.Orchestrators; using SFA.DAS.EmployerAccounts.Web.ViewModels; using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship; +using SFA.DAS.EmployerAccounts.Configuration; namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrchestratorTests { @@ -144,7 +145,7 @@ public void Arrange() _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _mapper.Object, Mock.Of()); } [Test] diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs index 3bbb156f29..fb2dcb788e 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using SFA.DAS.EAS.Account.Api.Client; using SFA.DAS.EmployerAccounts.Commands.ChangeTeamMemberRole; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models; using SFA.DAS.EmployerAccounts.Queries.GetAccountTeamMembers; @@ -30,7 +31,7 @@ public void Arrange() _accountApiClient = new Mock(); _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object, Mock.Of()); } [Test] diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs index 657aa9803f..6d7bc2cf2e 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using SFA.DAS.EAS.Account.Api.Client; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models; using SFA.DAS.EmployerAccounts.Models.AccountTeam; @@ -43,7 +44,7 @@ public void Arrange() _accountApiClient = new Mock(); _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object, Mock.Of()); _mediator.Setup(x => x.SendAsync(It.IsAny())) .ReturnsAsync(_teamMemberResponse); diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs index e04769d8b1..79d6a04b45 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using SFA.DAS.EAS.Account.Api.Client; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models.AccountTeam; using SFA.DAS.EmployerAccounts.Queries.GetAccountTeamMembers; @@ -35,7 +36,7 @@ public void Arrange() _accountApiClient = new Mock(); _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object, Mock.Of()); } [Test] diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs index 481e5d5ef8..4c5b9edbe7 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using SFA.DAS.EAS.Account.Api.Client; using SFA.DAS.EmployerAccounts.Commands.CreateInvitation; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models; using SFA.DAS.EmployerAccounts.Queries.GetAccountTeamMembers; @@ -33,7 +34,7 @@ public void Arrange() _mediator = new Mock(); _accountApiClient = new Mock(); _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object, Mock.Of()); } [Test] diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs index bebfe05d60..cb7aae39f4 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using SFA.DAS.EAS.Account.Api.Client; using SFA.DAS.EmployerAccounts.Commands.RemoveTeamMember; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models.AccountTeam; using SFA.DAS.EmployerAccounts.Models.UserProfile; @@ -35,7 +36,7 @@ public void Arrange() _accountApiClient = new Mock(); _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object); + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _mapper.Object, Mock.Of()); _mediator.Setup(x => x.SendAsync(It.IsAny())) .ReturnsAsync(new GetAccountTeamMembersResponse diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorWithCallToActionTests/WhenGettingAccount.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorWithCallToActionTests/WhenGettingAccount.cs index 2589908cb7..c2bc06cc48 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorWithCallToActionTests/WhenGettingAccount.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorWithCallToActionTests/WhenGettingAccount.cs @@ -26,6 +26,7 @@ using SFA.DAS.Common.Domain.Types; using SFA.DAS.NLog.Logger; using System.Net.Http; +using SFA.DAS.EmployerAccounts.Configuration; namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrchestratorWithCallToActionTests { @@ -137,7 +138,8 @@ public void Arrange() _mockAccountApiClient.Object, _mockMapper.Object, _mockAccountContext.Object, - _mockLogger.Object); + _mockLogger.Object, + Mock.Of()); } [Test] diff --git a/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs b/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs index 3b8c6e4d38..ad16d1260b 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Controllers/HomeController.cs @@ -114,9 +114,9 @@ public async Task Index() [HttpGet] [DasAuthorize] [Route("termsAndConditions")] - public ActionResult TermsAndConditions(string returnUrl) + public ActionResult TermsAndConditions(string returnUrl, string hashedAccountId) { - var termsAndConditionViewModel = new TermsAndConditionViewModel { ReturnUrl = returnUrl }; + var termsAndConditionViewModel = new TermsAndConditionViewModel { ReturnUrl = returnUrl, HashedAccountId = hashedAccountId }; return View(termsAndConditionViewModel); } @@ -127,6 +127,11 @@ public async Task TermsAndConditions(TermsAndConditionViewModel te { var userRef = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); await _homeOrchestrator.UpdateTermAndConditionsAcceptedOn(userRef); + + if (termsAndConditionViewModel.ReturnUrl == "EmployerTeam") + { + return RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerTeamControllerName, new { termsAndConditionViewModel.HashedAccountId }); + } return RedirectToAction(nameof(Index)); } diff --git a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs index ae87f869aa..ed9cad9d8d 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/ViewModels/TermsAndConditionViewModel.cs @@ -3,5 +3,6 @@ public class TermsAndConditionViewModel { public string ReturnUrl { get; set; } + public string HashedAccountId { get; set; } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml index 3d5300a11b..ebc72b28cc 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml @@ -32,7 +32,7 @@

- We've updated our terms of use. By continuing to use this service you are accepting the updated terms. + We've updated our terms of use. By continuing to use this service you are accepting the updated terms.

diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml index d83c649783..4942a79572 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml @@ -23,7 +23,7 @@

- We've updated our terms of use. By continuing to use this service you are accepting the updated terms. + We've updated our terms of use. By continuing to use this service you are accepting the updated terms.

diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml index d08bbf8ccd..d27e6f1fad 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml @@ -1,10 +1,20 @@ -@{ ViewBag.PageID = "page-terms-and-condition"; } -@{ ViewBag.Section = "home"; } -@{ ViewBag.Title = "Term and Conditions"; } -@*@{ ViewBag.HideNav = true; } -@{ ViewBag.HideAccounts = "true"; }*@ -@*@{ ViewBag.GaData.Vpv = "/page-auth-homepage"; }*@ -@{Layout = "~/Views/Shared/_Layout_CDN.cshtml"; } +@model SFA.DAS.EmployerAccounts.Web.ViewModels.TermsAndConditionViewModel +@{ + ViewBag.PageID = "page-terms-and-condition"; + ViewBag.Section = "home"; + ViewBag.Title = "Term and Conditions"; + Layout = "~/Views/Shared/_Layout_CDN.cshtml"; + string returnUrl = string.Empty; + if (Model.ReturnUrl == "EmployerTeam") + { + returnUrl = Url.Action("Index", "EmployerTeam", new { Model.HashedAccountId }); + } + else + { + returnUrl = Url.Action("Index", "Home"); + } + +}

Terms of use

@@ -96,13 +106,15 @@ We may update these terms and conditions at any time without notice. You’ll agree to any changes if you continue to use this service after the terms and conditions have been updated.  

+ @Html.HiddenFor(x => x.HashedAccountId) + @Html.HiddenFor(x => x.ReturnUrl)

- Cancel + Cancel



From 388ec4f3ebb6b995c1c2e6f7fd056100a230efc9 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 27 Aug 2021 12:20:02 +0100 Subject: [PATCH 07/14] adding more tests --- .../WhenIViewTermsAndCondition.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs index d98b4e96a4..76298912de 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs @@ -58,5 +58,51 @@ public void ThenTheViewIsReturned() Assert.IsNotNull(actual); Assert.IsAssignableFrom(actual); } + + [Test] + public void ThenTheViewModelIsMappedCorrectly() + { + //Act + var result = _homeController.TermsAndConditions("returnUrl", "hashedId"); + + //Assert + var viewResult = (ViewResult)result; + var viewModel = viewResult.Model; + + Assert.IsInstanceOf(viewModel); + var termsAndConditionViewModel = (TermsAndConditionViewModel)viewModel; + + Assert.AreEqual("returnUrl", termsAndConditionViewModel.ReturnUrl); + Assert.AreEqual("hashedId", termsAndConditionViewModel.HashedAccountId); + } + + + [Test] + public async Task ThenIsRedirectedToEmployerTeamController() + { + var termsAndConditionViewModel = new TermsAndConditionViewModel() { HashedAccountId = "HashedId", ReturnUrl = "EmployerTeam" }; + //Act + var result = await _homeController.TermsAndConditions(termsAndConditionViewModel); + + //Assert + var redirectResult = (RedirectToRouteResult)result; + + Assert.AreEqual("Index", redirectResult.RouteValues["action"].ToString()); + Assert.AreEqual("EmployerTeam", redirectResult.RouteValues["controller"].ToString()); + } + + [Test] + public async Task ThenIsRedirectedToHomeController() + { + var termsAndConditionViewModel = new TermsAndConditionViewModel() { HashedAccountId = "HashedId", ReturnUrl = "Home" }; + //Act + var result = await _homeController.TermsAndConditions(termsAndConditionViewModel); + + //Assert + var redirectResult = (RedirectToRouteResult)result; + + Assert.AreEqual("Index", redirectResult.RouteValues["action"].ToString()); + Assert.AreEqual("Home", redirectResult.RouteValues["controller"].ToString()); + } } } From 956686494664b9d9eaa6571ba519edb37a38e200 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 27 Aug 2021 14:44:10 +0100 Subject: [PATCH 08/14] test fix --- .../HomeControllerTests/WhenIViewTermsAndCondition.cs | 1 - .../WhenGettingAccount.cs | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs index 76298912de..8a7050a38c 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTermsAndCondition.cs @@ -102,7 +102,6 @@ public async Task ThenIsRedirectedToHomeController() var redirectResult = (RedirectToRouteResult)result; Assert.AreEqual("Index", redirectResult.RouteValues["action"].ToString()); - Assert.AreEqual("Home", redirectResult.RouteValues["controller"].ToString()); } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs index c32d1dc551..5806c0b6b7 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs @@ -30,6 +30,7 @@ using SFA.DAS.EmployerAccounts.Web.ViewModels; using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship; using SFA.DAS.EmployerAccounts.Configuration; +using SFA.DAS.EmployerAccounts.Queries.GetUserByRef; namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrchestratorTests { @@ -94,6 +95,15 @@ public void Arrange() UserRole = Role.Owner }); + _mediator.Setup(m => m.SendAsync(It.IsAny())) + .ReturnsAsync(new GetUserByRefResponse + { + User = new SFA.DAS.EmployerAccounts.Models.UserProfile.User + { + TermAndConditionsAcceptedOn = DateTime.Now + } + }); + _mediator.Setup(m => m.SendAsync(It.Is(q => q.HashedAccountId == HashedAccountId))) .ReturnsAsync(new GetAccountEmployerAgreementsResponse { From c63f455f1a47d9c0653e0db97a2436bace412df8 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 27 Aug 2021 15:07:29 +0100 Subject: [PATCH 09/14] CON-3860 adding more tests --- .../WhenIViewTheHomePage.cs | 70 +++++++++++++++++++ .../WhenGettingAccount.cs | 46 +++++++++++- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs index 59d18d773b..e48451e151 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/HomeControllerTests/WhenIViewTheHomePage.cs @@ -221,5 +221,75 @@ public async Task ThenIfIHaveMoreThanOneAccountIAmRedirectedToTheAccountsIndexPa Assert.IsNotNull(actualViewResult); Assert.AreEqual("", actualViewResult.ViewName); } + + [Test] + public async Task ThenIfIHaveMoreThanOneAccountIAmRedirectedToTheAccountsIndexPage_WithTermsAndConditionBannerDisplayed() + { + //Arrange + _owinWrapper.Setup(x => x.GetClaimValue("sub")).Returns(ExpectedUserId); + _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId, It.IsAny())).ReturnsAsync( + new OrchestratorResponse + { + Data = new UserAccountsViewModel + { + Accounts = new Accounts + { + AccountList = new List { new Account(), new Account() } + }, + + LastTermsAndConditionsUpdate = DateTime.Now, + TermAndConditionsAcceptedOn = DateTime.Now.AddDays(-20) + } + }); + + //Act + var actual = await _homeController.Index(); + + //Assert + Assert.IsNotNull(actual); + var actualViewResult = actual as ViewResult; + Assert.IsNotNull(actualViewResult); + + var viewModel = actualViewResult.Model; + Assert.IsInstanceOf>(viewModel); + var userAccountsViewModel = (OrchestratorResponse)viewModel; + + Assert.AreEqual(true, userAccountsViewModel.Data.ShowTermsAndConditionBanner); + } + + [Test] + public async Task ThenIfIHaveMoreThanOneAccountIAmRedirectedToTheAccountsIndexPage_WithTermsAndConditionBannerNotDisplayed() + { + //Arrange + _owinWrapper.Setup(x => x.GetClaimValue("sub")).Returns(ExpectedUserId); + _homeOrchestrator.Setup(x => x.GetUserAccounts(ExpectedUserId, It.IsAny())).ReturnsAsync( + new OrchestratorResponse + { + Data = new UserAccountsViewModel + { + Accounts = new Accounts + { + AccountList = new List { new Account(), new Account() } + }, + + LastTermsAndConditionsUpdate = DateTime.Now.AddDays(-20), + TermAndConditionsAcceptedOn = DateTime.Now + } + }); + + //Act + var actual = await _homeController.Index(); + + //Assert + Assert.IsNotNull(actual); + var actualViewResult = actual as ViewResult; + Assert.IsNotNull(actualViewResult); + + var viewModel = actualViewResult.Model; + Assert.IsInstanceOf>(viewModel); + var userAccountsViewModel = (OrchestratorResponse)viewModel; + + Assert.AreEqual(false, userAccountsViewModel.Data.ShowTermsAndConditionBanner); + } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs index 5806c0b6b7..fb86277887 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs @@ -48,6 +48,7 @@ public class WhenGettingAccount private Mock _mapper; private List _tasks; private AccountTask _testTask; + private DateTime LastTermsAndConditionsUpdate; [SetUp] public void Arrange() @@ -155,7 +156,10 @@ public void Arrange() _mapper = new Mock(); - _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _mapper.Object, Mock.Of()); + LastTermsAndConditionsUpdate = DateTime.Now.AddDays(-10); + var employerAccountsConfiguration = new EmployerAccountsConfiguration { LastTermsAndConditionsUpdate = LastTermsAndConditionsUpdate }; + + _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _mapper.Object, employerAccountsConfiguration); } [Test] @@ -171,6 +175,46 @@ public async Task ThenShouldGetAccountStats() Assert.AreEqual(_accountStats.TeamMemberCount, actual.Data.TeamMemberCount); } + [Test] + public async Task ThenShouldDispayTermsAndConditionBanner() + { + _mediator.Setup(m => m.SendAsync(It.IsAny())) + .ReturnsAsync(new GetUserByRefResponse + { + User = new SFA.DAS.EmployerAccounts.Models.UserProfile.User + { + TermAndConditionsAcceptedOn = LastTermsAndConditionsUpdate.AddDays(-1) + } + }); + + // Act + var actual = await _orchestrator.GetAccount(HashedAccountId, UserId); + + //Assert + Assert.IsNotNull(actual.Data); + Assert.AreEqual(true, actual.Data.ShowTermsAndConditionBanner); + } + + [Test] + public async Task ThenShouldNotDispayTermsAndConditionBanner() + { + _mediator.Setup(m => m.SendAsync(It.IsAny())) + .ReturnsAsync(new GetUserByRefResponse + { + User = new SFA.DAS.EmployerAccounts.Models.UserProfile.User + { + TermAndConditionsAcceptedOn = LastTermsAndConditionsUpdate.AddDays(1) + } + }); + + // Act + var actual = await _orchestrator.GetAccount(HashedAccountId, UserId); + + //Assert + Assert.IsNotNull(actual.Data); + Assert.AreEqual(false, actual.Data.ShowTermsAndConditionBanner); + } + [Test] public async Task ThenShouldReturnTasks() { From bb239cd590b38003a3f3f5e96c9e683c293bc1c5 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 6 Sep 2021 14:13:09 +0100 Subject: [PATCH 10/14] CON-3860 & CON-3921 --- .../SFA.DAS.EAS.Employer_Account.Database.sqlproj | 1 + ...CON-3921-DataFixForTermAndConditionsAcceptedOn.sql | 11 +++++++++++ .../StoredProcedures/UpsertUser.sql | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj b/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj index dcd26449d8..cebe73acaf 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj +++ b/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj @@ -168,6 +168,7 @@ + diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql new file mode 100644 index 0000000000..f50f184935 --- /dev/null +++ b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql @@ -0,0 +1,11 @@ +-- Update TermsAndConditionsAcceptedOn for all users created afer 27th July 2021 + Update [employer_account].[User] + Set TermAndConditionsAcceptedOn = GETDATE() + where Id in ( + Select UserId from ( + Select *, ROW_NUMBER() over (partition by M.UserId order by M.CreatedDate) As Rank2 + from [employer_account].[Membership] M + ) Result + Where Result.Rank2 = 1 + and CreatedDate >= CONVERT(DATETIME,'27/07/2021',103) --dd/MM/yyyy + ) \ No newline at end of file diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql b/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql index 8a4c620b2b..b618b3ef3d 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql +++ b/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql @@ -9,4 +9,4 @@ AS USING (SELECT @userRef AS UserRef) AS [Source] ON [Target].UserRef = [Source].UserRef WHEN MATCHED THEN UPDATE SET [Target].Email = @email, [Target].FirstName = @firstName, [Target].LastName = @lastName, [Target].CorrelationId = COALESCE(@correlationId, [Target].CorrelationId) - WHEN NOT MATCHED THEN INSERT (UserRef, Email, FirstName, LastName, CorrelationId) VALUES (@userRef, @email, @firstName, @lastName, @correlationId); + WHEN NOT MATCHED THEN INSERT (UserRef, Email, FirstName, LastName, CorrelationId, TermAndConditionsAcceptedOn) VALUES (@userRef, @email, @firstName, @lastName, @correlationId, GETDATE()); From ce0a70cf7121e8b1b9658494678762cea77dcb64 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 8 Sep 2021 10:03:51 +0100 Subject: [PATCH 11/14] sql fix --- ...3921-DataFixForTermAndConditionsAcceptedOn.sql | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql index f50f184935..ba56e2d01d 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql +++ b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql @@ -1,11 +1,12 @@ --- Update TermsAndConditionsAcceptedOn for all users created afer 27th July 2021 - Update [employer_account].[User] - Set TermAndConditionsAcceptedOn = GETDATE() - where Id in ( - Select UserId from ( +-- Update TermsAndConditionsAcceptedOn for all users created afer 28th July 2021 + Update U + Set U. TermAndConditionsAcceptedOn = T.CreatedDate + From [employer_account].[User] U + Inner join ( + Select UserId, CreatedDate from ( Select *, ROW_NUMBER() over (partition by M.UserId order by M.CreatedDate) As Rank2 from [employer_account].[Membership] M ) Result Where Result.Rank2 = 1 - and CreatedDate >= CONVERT(DATETIME,'27/07/2021',103) --dd/MM/yyyy - ) \ No newline at end of file + and CreatedDate >= CONVERT(DATETIME,'28/07/2021',103) --dd/MM/yyyy + ) T on U.Id = T.UserId \ No newline at end of file From 906c997eae9b58a065ebc026ebd526a426f5286f Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 8 Sep 2021 10:54:44 +0100 Subject: [PATCH 12/14] Removed erroneous space --- .../Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql index ba56e2d01d..8bc0618a57 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql +++ b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql @@ -1,6 +1,6 @@ -- Update TermsAndConditionsAcceptedOn for all users created afer 28th July 2021 Update U - Set U. TermAndConditionsAcceptedOn = T.CreatedDate + Set U.TermAndConditionsAcceptedOn = T.CreatedDate From [employer_account].[User] U Inner join ( Select UserId, CreatedDate from ( From a7ac8131446ce771d1357be0bd5f0e54c7eec868 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 13 Sep 2021 13:02:34 +0100 Subject: [PATCH 13/14] CON-3860 removed code to open in new tab --- .../Views/EmployerTeam/Index.cshtml | 2 +- src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml index ebc72b28cc..4fd37e2f85 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/EmployerTeam/Index.cshtml @@ -32,7 +32,7 @@

- We've updated our terms of use. By continuing to use this service you are accepting the updated terms. + We've updated our terms of use. By continuing to use this service you are accepting the updated terms.

diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml index 4942a79572..43303ba8b7 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/Index.cshtml @@ -23,7 +23,7 @@

- We've updated our terms of use. By continuing to use this service you are accepting the updated terms. + We've updated our terms of use. By continuing to use this service you are accepting the updated terms.

From 0a41a6e3124b9d876fe3eef1c88487577c356230 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 13 Sep 2021 14:51:22 +0100 Subject: [PATCH 14/14] CON-3860 links updated --- .../Views/Home/TermsAndConditions.cshtml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml index d27e6f1fad..54c7c2dec2 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Home/TermsAndConditions.cshtml @@ -34,7 +34,7 @@ Keep your sign in details secure and do not share them with third parties 
  • - If you are a commercial organisation as defined in section 54 of the Modern Slavery Act 2015, adhere to the annual reporting requirements + If you are a commercial organisation as defined in section 54 of the Modern Slavery Act 2015, adhere to the annual reporting requirements
  • Not provide feedback on a training provider when you are an employer provider @@ -64,24 +64,24 @@ Input truthful and accurate information  
  • - Adhere to the Computer Misuse Act 1990 + Adhere to the Computer Misuse Act 1990
  • - Not use discriminatory wording set out in the Equality Act 2010 + Not use discriminatory wording set out in the Equality Act 2010
  • - Make sure the published rates of pay comply with the National minimum wage guidelines and are not misleading to candidates   + Make sure the published rates of pay comply with the National minimum wage guidelines and are not misleading to candidates  
  • - Adhere to all relevant UK employment laws  + Adhere to all relevant UK employment laws 
  • Your apprenticeship adverts being publicly accessible, including the possibility of partner websites displaying them  
  • - Comply with the government safeguarding policies for children  and vulnerable adults + Comply with the government safeguarding policies for children  and vulnerable adults