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();