diff --git a/src/.cr/personal/Navigation/RecentFilesHistory.xml b/src/.cr/personal/Navigation/RecentFilesHistory.xml
new file mode 100644
index 0000000000..89fc590ebe
--- /dev/null
+++ b/src/.cr/personal/Navigation/RecentFilesHistory.xml
@@ -0,0 +1,100 @@
+
+
+
+
+ -
+ EmployerTeamController.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\controllers\employerteamcontroller.cs
+
+
- Controllers
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ EmployerTeamController.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\controllers\employerteamcontroller.cs
+
+
- Controllers
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ UrlHelperExtensions.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\extensions\urlhelperextensions.cs
+
+
- Extensions
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ UrlHelperExtensions.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.eas.support.web\extensions\urlhelperextensions.cs
+
+
- Extensions
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EAS.Support.Web\SFA.DAS.EAS.Support.Web.csproj
+ SFA.DAS.EAS.Support.Web
+
+ -
+ EmployerTeamOrchestrator.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\orchestrators\employerteamorchestrator.cs
+
+
- Orchestrators
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ EmployerTeamController.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\controllers\employerteamcontroller.cs
+
+
- Controllers
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ EmployerTeam
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\views\employerteam\
+
+
- Views
+
+ Folder
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ EmployerTeamController.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web\controllers\employerteamcontroller.cs
+
+
- Controllers
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web\SFA.DAS.EmployerAccounts.Web.csproj
+ SFA.DAS.EmployerAccounts.Web
+
+ -
+ GetReservationsRequestHandler.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts\queries\getreservations\getreservationsrequesthandler.cs
+
+
- Queries
+ - GetReservations
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts\SFA.DAS.EmployerAccounts.csproj
+ SFA.DAS.EmployerAccounts
+
+ -
+ WhenGettingAccount.cs
+ c:\esfa\das-employerapprenticeshipsservice\src\sfa.das.employeraccounts.web.unittests\orchestrators\employerteamorchestratortests\whengettingaccount.cs
+
+
- Orchestrators
+ - EmployerTeamOrchestratorTests
+
+ C:\ESFA\das-employerapprenticeshipsservice\src\SFA.DAS.EmployerAccounts.Web.UnitTests\SFA.DAS.EmployerAccounts.Web.UnitTests.csproj
+ SFA.DAS.EmployerAccounts.Web.UnitTests
+
+
+
+
\ No newline at end of file
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Mappings/WhenAutoMapping.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Mappings/WhenAutoMapping.cs
index 976f724954..f09ff9fc02 100644
--- a/src/SFA.DAS.EmployerAccounts.UnitTests/Mappings/WhenAutoMapping.cs
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Mappings/WhenAutoMapping.cs
@@ -21,6 +21,8 @@ public void ThenShouldUseValidConfiguration()
c.AddProfile();
c.AddProfile();
c.AddProfile();
+ c.AddProfile();
+ c.AddProfile();
});
config.AssertConfigurationIsValid();
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs
new file mode 100644
index 0000000000..0545fb979a
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs
@@ -0,0 +1,78 @@
+using Moq;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship;
+using SFA.DAS.Validation;
+using System;
+using NUnit.Framework;
+using SFA.DAS.NLog.Logger;
+using System.Threading.Tasks;
+using SFA.DAS.CommitmentsV2.Api.Types.Responses;
+using System.Collections.Generic;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.HashingService;
+
+namespace SFA.DAS.EmployerAccounts.UnitTests.Queries.GetApprenticeship
+{
+ public class WhenIGetApprenticeship : QueryBaseTest
+ {
+ public override GetApprenticeshipsRequest Query { get; set; }
+ public override GetApprenticeshipsHandler RequestHandler { get; set; }
+ public override Mock> RequestValidator { get; set; }
+
+ private Mock _commitmentV2Service;
+ private Mock _hashingService;
+ private Mock _logger;
+ private long _accountId;
+ private string _hashedAccountId;
+
+ [SetUp]
+ public void Arrange()
+ {
+ SetUp();
+
+ _accountId = 123;
+ _hashedAccountId = "ABC123";
+ _logger = new Mock();
+
+ _commitmentV2Service = new Mock();
+ _hashingService = new Mock();
+
+ _commitmentV2Service.Setup(m => m.GetApprenticeships(_accountId)).ReturnsAsync(new List { new Apprenticeship { Id = 3 } });
+ _hashingService = new Mock();
+ _hashingService.Setup(x => x.DecodeValue(_hashedAccountId)).Returns(_accountId);
+
+ RequestHandler = new GetApprenticeshipsHandler(RequestValidator.Object, _logger.Object, _commitmentV2Service.Object, _hashingService.Object);
+
+ Query = new GetApprenticeshipsRequest
+ {
+ HashedAccountId = _hashedAccountId
+ };
+ }
+
+
+ public override Task ThenIfTheMessageIsValidTheRepositoryIsCalled()
+ {
+ throw new NotImplementedException();
+ }
+
+ [Test]
+ public async Task ThenIfTheMessageIsValidTheServiceIsCalled()
+ {
+ //Act
+ await RequestHandler.Handle(Query);
+
+ //Assert
+ _commitmentV2Service.Verify(x => x.GetApprenticeships(_accountId), Times.Once);
+ }
+
+ [Test]
+ public override async Task ThenIfTheMessageIsValidTheValueIsReturnedInTheResponse()
+ {
+ //Act
+ var response = await RequestHandler.Handle(Query);
+
+ //Assert
+ Assert.IsNotNull(response.Apprenticeships);
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIValidateTheRequest.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIValidateTheRequest.cs
new file mode 100644
index 0000000000..7058fb865a
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIValidateTheRequest.cs
@@ -0,0 +1,47 @@
+using NUnit.Framework;
+using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship;
+
+namespace SFA.DAS.EmployerAccounts.UnitTests.Queries.GetApprenticeship
+{
+ public class WhenIValidateTheRequest
+ {
+ private GetApprenticeshipsValidator _validator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ _validator = new GetApprenticeshipsValidator();
+ }
+
+
+ [Test]
+ public void ThenShouldReturnValidIfRequestIsValid()
+ {
+ //Act
+ var result = _validator.Validate(new GetApprenticeshipsRequest { HashedAccountId = "123ABC", ExternalUserId = "user123" });
+
+ //Assert
+ Assert.IsTrue(result.IsValid());
+ }
+
+ [Test]
+ public void ThenShouldReturnInvalidIfNoAccountIdIsProvided()
+ {
+ //Act
+ var result = _validator.Validate(new GetApprenticeshipsRequest { ExternalUserId = "user123" });
+
+ //Assert
+ Assert.IsFalse(result.IsValid());
+ }
+
+ [Test]
+ public void ThenShouldReturnInValidIfRequestIsNotValid()
+ {
+ //Act
+ var result = _validator.Validate(new GetApprenticeshipsRequest { });
+
+ //Assert
+ Assert.IsFalse(result.IsValid());
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs
new file mode 100644
index 0000000000..a739f3ea8a
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs
@@ -0,0 +1,84 @@
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Queries.GetSingleCohort;
+using SFA.DAS.Encoding;
+using SFA.DAS.HashingService;
+using SFA.DAS.NLog.Logger;
+using SFA.DAS.Validation;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SFA.DAS.EmployerAccounts.UnitTests.Queries.GetSingleCohort
+{
+ public class WhenIGetSingleCohort : QueryBaseTest
+ {
+ public override GetSingleCohortRequest Query { get; set; }
+ public override GetSingleCohortRequestHandler RequestHandler { get; set; }
+ public override Mock> RequestValidator { get; set; }
+ private Mock _commitmentV2Service;
+ private Mock _hashingService;
+ private long _accountId;
+ private long _cohortId;
+ public string hashedAccountId;
+
+ [SetUp]
+ public void Arrange()
+ {
+ SetUp();
+
+ _accountId = 123;
+ _cohortId = 1;
+ hashedAccountId = "Abc123";
+
+ _commitmentV2Service = new Mock();
+ _commitmentV2Service.Setup(m => m.GetCohorts(_accountId))
+ .ReturnsAsync(new List() { new Cohort { Id = _cohortId, NumberOfDraftApprentices = 1 }});
+
+ _commitmentV2Service.Setup(m => m.GetDraftApprenticeships(It.IsAny()))
+ .ReturnsAsync(new List { new Apprenticeship { CourseName = "CourseName" } });
+
+ _hashingService = new Mock();
+ _hashingService.Setup(x => x.DecodeValue(hashedAccountId)).Returns(_accountId);
+
+ RequestHandler = new GetSingleCohortRequestHandler(RequestValidator.Object, _commitmentV2Service.Object, _hashingService.Object);
+
+ Query = new GetSingleCohortRequest
+ {
+ HashedAccountId = hashedAccountId
+ };
+ }
+
+
+ [Test]
+ public override async Task ThenIfTheMessageIsValidTheValueIsReturnedInTheResponse()
+ {
+ //Act
+ var response = await RequestHandler.Handle(Query);
+
+ //Assert
+ Assert.IsNotNull(response.Cohort);
+ Assert.IsTrue(response.Cohort.NumberOfDraftApprentices.Equals(1));
+ Assert.IsTrue(response.Cohort?.Apprenticeships.Count().Equals(1));
+ }
+
+
+ [Test]
+ public async Task ThenIfTheMessageIsValidTheServiceIsCalled()
+ {
+ //Act
+ await RequestHandler.Handle(Query);
+
+ //Assert
+ _commitmentV2Service.Verify(x => x.GetCohorts(_accountId), Times.Once);
+ }
+
+ public override Task ThenIfTheMessageIsValidTheRepositoryIsCalled()
+ {
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIValidateTheRequest.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIValidateTheRequest.cs
new file mode 100644
index 0000000000..436db00ba8
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIValidateTheRequest.cs
@@ -0,0 +1,36 @@
+using NUnit.Framework;
+using SFA.DAS.EmployerAccounts.Queries.GetSingleCohort;
+
+namespace SFA.DAS.EmployerAccounts.UnitTests.Queries.GetSingleCohort
+{
+ public class WhenIValidateTheRequest
+ {
+ private GetSingleCohortRequestValidator _validator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ _validator = new GetSingleCohortRequestValidator();
+ }
+
+ [Test]
+ public void ThenShouldReturnValidIfRequestIsValid()
+ {
+ //Act
+ var result = _validator.Validate(new GetSingleCohortRequest { HashedAccountId = "Abc123" });
+
+ //Assert
+ Assert.IsTrue(result.IsValid());
+ }
+
+ [Test]
+ public void ThenShouldReturnInValidIfRequestIsNotValid()
+ {
+ //Act
+ var result = _validator.Validate(new GetSingleCohortRequest { HashedAccountId = string.Empty });
+
+ //Assert
+ Assert.IsFalse(result.IsValid());
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Services/AccountCohorts/WhenIGetAccountCohorts.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Services/AccountCohorts/WhenIGetAccountCohorts.cs
new file mode 100644
index 0000000000..9041539bdd
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Services/AccountCohorts/WhenIGetAccountCohorts.cs
@@ -0,0 +1,169 @@
+using SFA.DAS.CommitmentsV2.Api.Client;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using AutoMapper;
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.EmployerAccounts.Services;
+using SFA.DAS.CommitmentsV2.Api.Types.Requests;
+using System.Threading;
+using SFA.DAS.CommitmentsV2.Api.Types.Responses;
+using SFA.DAS.CommitmentsV2.Types;
+using SFA.DAS.CommitmentsV2.Types.Dtos;
+using System.Linq;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.Encoding;
+
+namespace SFA.DAS.EmployerAccounts.UnitTests.Services.AccountCohorts
+{
+ public class WhenIGetAccountCohorts
+ {
+ private Mock _mockCommitmentsApiClient;
+ private Mock _mockEncodingService;
+ private Mock _mockMapper;
+ private long _accountId = 123;
+ private CommitmentsV2Service _sut;
+
+ [SetUp]
+ public void Arrange()
+ {
+ _mockMapper = new Mock();
+ _mockCommitmentsApiClient = new Mock();
+ _mockEncodingService = new Mock();
+ _sut = new CommitmentsV2Service(_mockCommitmentsApiClient.Object, _mockMapper.Object, _mockEncodingService.Object);
+ }
+
+ [Test]
+ public async Task ThenGetApprenticeshipsResponse()
+ {
+ //Arrange
+ _mockCommitmentsApiClient
+ .Setup(c => c.GetApprenticeships(It.Is(r => r.AccountId == _accountId), CancellationToken.None))
+ .Returns(Task.FromResult(CreateApprenticeshipResponse()));
+ var apprenticeships = new List { new Apprenticeship { ApprenticeshipStatus = EmployerAccounts.Models.CommitmentsV2.ApprenticeshipStatus.Approved, FirstName ="FirstName" , LastName = "LastName" } };
+ _mockMapper
+ .Setup(m => m.Map, IEnumerable>
+ (It.IsAny>(),
+ It.IsAny, IEnumerable>>>()))
+ .Returns(apprenticeships);
+
+ //Act
+ var result =await _sut.GetApprenticeships(_accountId);
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result.Count().Equals(1));
+ }
+
+ [Test]
+ public async Task ThenGetCohortsResponse()
+ {
+ //Arrange
+ _mockCommitmentsApiClient.Setup(c => c.GetCohorts(It.Is(r => r.AccountId == _accountId), CancellationToken.None))
+ .Returns(Task.FromResult(GetCohortsResponseForWithTrainingProviderStaus()));
+ _mockEncodingService.Setup(x => x.Encode(It.IsAny(), EncodingType.CohortReference)).Returns((long y, EncodingType z) => y + "_Encoded");
+
+ var cohorts = new List()
+ {
+ new Cohort { Id = 1 }
+ };
+
+ _mockMapper.Setup(m => m.Map, IEnumerable>(It.IsAny(),
+ It.IsAny, IEnumerable>>>()))
+ .Returns(cohorts);
+
+ //Act
+ var result = await _sut.GetCohorts(_accountId);
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result.Count().Equals(1));
+ }
+
+ [Test]
+ public async Task ThenGetDraftApprenticeshipsResponse()
+ {
+ //Arrange
+ _mockCommitmentsApiClient.Setup(c => c.GetDraftApprenticeships(123, It.IsAny())).Returns(Task.FromResult(GetDraftApprenticeshipsResponse()));
+ var apprenticeships = new List { new Apprenticeship { FirstName = "FirstName", LastName = "LastName" } };
+ _mockMapper.Setup(m => m.Map, IEnumerable>(It.IsAny>(),
+ It.IsAny, IEnumerable>>>()))
+ .Returns(apprenticeships);
+
+
+ //Act
+ var result = await _sut.GetDraftApprenticeships(new Cohort {Id = 123});
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.IsTrue(result.Count().Equals(1));
+ }
+
+
+ private GetApprenticeshipsResponse CreateApprenticeshipResponse()
+ {
+ IEnumerable apprenticeships = new List()
+ {
+ new GetApprenticeshipsResponse.ApprenticeshipDetailsResponse
+ {
+ Id = 1,
+ FirstName = "FirstName",
+ LastName = "LastName",
+ Uln = "Uln",
+ EmployerName = "EmployerName",
+ CourseName = "CourseName",
+ StartDate = new DateTime(2020, 5, 1),
+ EndDate = new DateTime(2022, 5, 1),
+ ApprenticeshipStatus = SFA.DAS.CommitmentsV2.Types.ApprenticeshipStatus.Live,
+ ProviderName = "ProviderName"
+ }
+ };
+
+ return new GetApprenticeshipsResponse() { Apprenticeships = apprenticeships, TotalApprenticeships = 1, TotalApprenticeshipsFound = 1, TotalApprenticeshipsWithAlertsFound = 0 };
+ }
+
+
+ private GetCohortsResponse GetCohortsResponseForWithTrainingProviderStaus()
+ {
+ IEnumerable cohorts = new List()
+ {
+ new CohortSummary
+ {
+ CohortId = 4,
+ AccountId = 1,
+ ProviderId = 4,
+ ProviderName = "Provider4",
+ NumberOfDraftApprentices = 1,
+ IsDraft = false,
+ WithParty = Party.Provider,
+ CreatedOn = DateTime.Now
+ },
+ };
+
+ return new GetCohortsResponse(cohorts);
+ }
+
+ private GetDraftApprenticeshipsResponse GetDraftApprenticeshipsResponse()
+ {
+ IReadOnlyCollection draftApprenticeships = new List()
+ {
+ new DraftApprenticeshipDto
+ {
+ Id = 1,
+ FirstName = "FirstName",
+ LastName = "LastName",
+ DateOfBirth = new DateTime(2000, 1 ,1 ),
+ Cost = 100,
+ StartDate = new DateTime(2020, 5, 1),
+ EndDate = new DateTime(2022, 5, 1),
+ CourseCode = "CourseCode",
+ CourseName = "CourseName"
+ }
+ };
+
+ var draftApprenticeshipsResponse = new GetDraftApprenticeshipsResponse() { DraftApprenticeships = draftApprenticeships };
+ return draftApprenticeshipsResponse;
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenFundsToReserve.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenFundsToReserve.cs
index 806a1bcfb8..2a172c70cf 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenFundsToReserve.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenFundsToReserve.cs
@@ -45,16 +45,17 @@ public void Arrange()
public void ThenForNonLevyTheCheckFundingViewIsReturnedAtRow1Panel1()
{
// Arrange
- var model = new AccountDashboardViewModel();
- model.PayeSchemeCount = 1;
- model.CallToActionViewModel = new CallToActionViewModel
+ var model = new AccountDashboardViewModel()
{
- AgreementsToSign = false,
- VacanciesViewModel = new VacanciesViewModel { VacancyCount = 0 }
+ PayeSchemeCount = 1,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ AgreementsToSign = false,
+ VacanciesViewModel = new VacanciesViewModel()
+ },
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy
};
- model.ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy;
-
//Act
var result = _controller.Row1Panel1(model) as PartialViewResult;
@@ -74,8 +75,7 @@ public void ThenForNonLevyTheContinueSetupForSingleReservationViewIsReturnedAtRo
{
AgreementsToSign = false,
Reservations = new List { new Reservation { Status = ReservationStatus.Pending } },
- VacanciesViewModel = new VacanciesViewModel { VacancyCount = 0 },
- ApprenticeshipAdded = false
+ VacanciesViewModel = new VacanciesViewModel()
};
model.ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy;
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprentice.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprentice.cs
new file mode 100644
index 0000000000..d18178923e
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprentice.cs
@@ -0,0 +1,85 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.Authentication;
+using SFA.DAS.Authorization.Services;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Models.Reservations;
+using SFA.DAS.EmployerAccounts.Web.Controllers;
+using SFA.DAS.EmployerAccounts.Web.Orchestrators;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+
+namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.EmployerTeamControllerTests.WhenCallToActionToggleIsEnabled
+{
+ public class WhenSetupSingleApprentice
+ {
+ private EmployerTeamController _controller;
+
+ private Mock mockAuthenticationService;
+ private Mock mockAuthorizationService;
+ private Mock mockMultiVariantTestingService;
+ private Mock> mockCookieStorageService;
+ private Mock mockEmployerTeamOrchestrator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ mockAuthenticationService = new Mock();
+ mockAuthorizationService = new Mock();
+ mockMultiVariantTestingService = new Mock();
+ mockCookieStorageService = new Mock>();
+ mockEmployerTeamOrchestrator = new Mock();
+
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.HomePage")).Returns(false);
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.CallToAction")).Returns(true);
+
+ _controller = new EmployerTeamController(
+ mockAuthenticationService.Object,
+ mockMultiVariantTestingService.Object,
+ mockCookieStorageService.Object,
+ mockEmployerTeamOrchestrator.Object,
+ mockAuthorizationService.Object);
+ }
+
+ [Test]
+ public void ThenForNonLevyTheContinueSetupForSingleApprenticeshipViewIsReturnedAtRow1Panel1()
+ {
+ //Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Completed } },
+ Cohorts = new List
+ {
+ new CohortViewModel
+ {
+ NumberOfDraftApprentices = 1,
+ CohortStatus = CohortStatus.Draft,
+ Apprenticeships = new List
+ {
+ new ApprenticeshipViewModel
+ {
+ ApprenticeshipStatus = ApprenticeshipStatus.Draft,
+ NumberOfDraftApprentices = 1
+ }
+ }
+ }
+ }
+ }
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("SingleApprenticeshipContinueSetup", (result.Model as dynamic).ViewName);
+ }
+
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeByProvider.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeByProvider.cs
new file mode 100644
index 0000000000..b6dd6b010a
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeByProvider.cs
@@ -0,0 +1,83 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.Authentication;
+using SFA.DAS.Authorization.Services;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Models.Reservations;
+using SFA.DAS.EmployerAccounts.Web.Controllers;
+using SFA.DAS.EmployerAccounts.Web.Orchestrators;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+
+namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.EmployerTeamControllerTests.WhenCallToActionToggleIsEnabled
+{
+ public class WhenSetupSingleApprenticeByProvider
+ {
+ private EmployerTeamController _controller;
+
+ private Mock mockAuthenticationService;
+ private Mock mockAuthorizationService;
+ private Mock mockMultiVariantTestingService;
+ private Mock> mockCookieStorageService;
+ private Mock mockEmployerTeamOrchestrator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ mockAuthenticationService = new Mock();
+ mockAuthorizationService = new Mock();
+ mockMultiVariantTestingService = new Mock();
+ mockCookieStorageService = new Mock>();
+ mockEmployerTeamOrchestrator = new Mock();
+
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.HomePage")).Returns(false);
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.CallToAction")).Returns(true);
+
+ _controller = new EmployerTeamController(
+ mockAuthenticationService.Object,
+ mockMultiVariantTestingService.Object,
+ mockCookieStorageService.Object,
+ mockEmployerTeamOrchestrator.Object,
+ mockAuthorizationService.Object);
+ }
+
+ [Test]
+ public void ThenForNonLevyContinueSetupForSingleApprenticeshipByProviderViewIsReturnedAtRow1Panel1()
+ {
+ //Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Completed } },
+ Cohorts = new List
+ {
+ new CohortViewModel
+ {
+ NumberOfDraftApprentices = 0,
+ CohortStatus = CohortStatus.WithTrainingProvider,
+ Apprenticeships = new List()
+ {
+ new ApprenticeshipViewModel
+ {
+ ApprenticeshipStatus = ApprenticeshipStatus.Draft
+ }
+ }
+ }
+ }
+ }
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("SingleApprenticeshipContinueWithProvider", (result.Model as dynamic).ViewName);
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeStatus.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeStatus.cs
new file mode 100644
index 0000000000..8efbef0d4a
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleApprenticeStatus.cs
@@ -0,0 +1,156 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.Authentication;
+using SFA.DAS.Authorization.Services;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Models.Reservations;
+using SFA.DAS.EmployerAccounts.Web.Controllers;
+using SFA.DAS.EmployerAccounts.Web.Orchestrators;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+
+namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.EmployerTeamControllerTests.WhenCallToActionToggleIsEnabled
+{
+ public class WhenSetupSingleApprenticeStatus
+ {
+ private EmployerTeamController _controller;
+
+ private Mock mockAuthenticationService;
+ private Mock mockAuthorizationService;
+ private Mock mockMultiVariantTestingService;
+ private Mock> mockCookieStorageService;
+ private Mock mockEmployerTeamOrchestrator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ mockAuthenticationService = new Mock();
+ mockAuthorizationService = new Mock();
+ mockMultiVariantTestingService = new Mock();
+ mockCookieStorageService = new Mock>();
+ mockEmployerTeamOrchestrator = new Mock();
+
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.HomePage")).Returns(false);
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.CallToAction")).Returns(true);
+
+ _controller = new EmployerTeamController(
+ mockAuthenticationService.Object,
+ mockMultiVariantTestingService.Object,
+ mockCookieStorageService.Object,
+ mockEmployerTeamOrchestrator.Object,
+ mockAuthorizationService.Object);
+ }
+
+ [Test]
+ public void ThenForNonLevyTheYourSingleApprovedApprenticeViewIsReturnedAtRow1Panel1()
+ {
+ //Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Completed } },
+ Apprenticeships = new List()
+ {
+ new ApprenticeshipViewModel()
+ {
+ ApprenticeshipStatus =ApprenticeshipStatus.Approved
+ }
+ }
+ }
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("SingleApprenticeshipApproved", (result.Model as dynamic).ViewName);
+ }
+
+
+ [Test]
+ public void ThenForNonLevyTheYourSingleApprenticeWithTrainingProviderStatusViewIsReturnedAtRow1Panel1()
+ {
+ //Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Completed } },
+
+ Cohorts = new List
+ {
+ new CohortViewModel
+ {
+ //CohortsCount = 1,
+ NumberOfDraftApprentices = 1,
+ CohortStatus = CohortStatus.WithTrainingProvider,
+ Apprenticeships = new List()
+ {
+ new ApprenticeshipViewModel
+ {
+ ApprenticeshipStatus = ApprenticeshipStatus.Draft,
+ NumberOfDraftApprentices = 1
+ }
+ }
+ }
+ }
+ }
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("SingleApprenticeshipWithTrainingProvider", (result.Model as dynamic).ViewName);
+ }
+
+
+ [Test]
+ public void ThenForNonLevyTheYourSingleApprenticeReadyForReviewStatusViewIsReturnedAtRow1Panel1()
+ {
+ //Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Completed } },
+ Cohorts = new List
+ {
+ new CohortViewModel
+ {
+ //CohortsCount = 1,
+ NumberOfDraftApprentices = 1,
+ CohortStatus = CohortStatus.Review,
+ Apprenticeships = new List()
+ {
+ new ApprenticeshipViewModel
+ {
+ ApprenticeshipStatus = ApprenticeshipStatus.Draft,
+ NumberOfDraftApprentices = 1
+ }
+ }
+ }
+ }
+ }
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("SingleApprenticeshipReadyForReview", (result.Model as dynamic).ViewName);
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleReservation.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleReservation.cs
new file mode 100644
index 0000000000..c8db181f7e
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenCallToActionToggleIsEnabled/WhenSetupSingleReservation.cs
@@ -0,0 +1,71 @@
+using System.Collections.Generic;
+using System.Web.Mvc;
+using Moq;
+using NUnit.Framework;
+using SFA.DAS.Authentication;
+using SFA.DAS.Authorization.Services;
+using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models.Reservations;
+using SFA.DAS.EmployerAccounts.Web.Controllers;
+using SFA.DAS.EmployerAccounts.Web.Orchestrators;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+
+namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Controllers.EmployerTeamControllerTests.WhenCallToActionToggleIsEnabled
+{
+ public class WhenSetupSingleReservation
+ {
+ private EmployerTeamController _controller;
+
+ private Mock mockAuthenticationService;
+ private Mock mockAuthorizationService;
+ private Mock mockMultiVariantTestingService;
+ private Mock> mockCookieStorageService;
+ private Mock mockEmployerTeamOrchestrator;
+
+ [SetUp]
+ public void Arrange()
+ {
+ mockAuthenticationService = new Mock();
+ mockAuthorizationService = new Mock();
+ mockMultiVariantTestingService = new Mock();
+ mockCookieStorageService = new Mock>();
+ mockEmployerTeamOrchestrator = new Mock();
+
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.HomePage")).Returns(false);
+ mockAuthorizationService.Setup(m => m.IsAuthorized("EmployerFeature.CallToAction")).Returns(true);
+
+ _controller = new EmployerTeamController(
+ mockAuthenticationService.Object,
+ mockMultiVariantTestingService.Object,
+ mockCookieStorageService.Object,
+ mockEmployerTeamOrchestrator.Object,
+ mockAuthorizationService.Object);
+ }
+
+
+ [Test]
+ public void ThenForNonLevyTheContinueSetupForSingleReservationViewIsReturnedAtRow1Panel1()
+ {
+ // Arrange
+ var model = new AccountDashboardViewModel()
+ {
+ PayeSchemeCount = 1,
+ CallToActionViewModel = new CallToActionViewModel
+ {
+ Reservations = new List { new Reservation { Status = ReservationStatus.Pending } },
+ VacanciesViewModel = new VacanciesViewModel()
+ },
+ ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy
+ };
+
+ //Act
+ var result = _controller.Row1Panel1(model) as PartialViewResult;
+
+ //Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual("ContinueSetupForSingleReservation", (result.Model as dynamic).ViewName);
+ Assert.AreEqual(PanelType.Summary, (result.Model as dynamic).PanelType);
+ }
+
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenNoPayeScheme.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenNoPayeScheme.cs
index 611ba7f24e..36d7c85657 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenNoPayeScheme.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Controllers/EmployerTeamControllerTests/WhenNoPayeScheme.cs
@@ -44,11 +44,7 @@ public void ThenTheAddPayeViewIsReturnedAtRow1Panel1()
{
// Arrange
var model = new AccountDashboardViewModel();
- model.PayeSchemeCount = 0;
- model.CallToActionViewModel = new CallToActionViewModel
- {
- ApprenticeshipAdded = false
- };
+ model.PayeSchemeCount = 0;
//Act
var result = _controller.Row1Panel1(model) as PartialViewResult;
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Extensions/CohortSummaryExtensionTests.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Extensions/CohortSummaryExtensionTests.cs
new file mode 100644
index 0000000000..9b5cbb81ed
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Extensions/CohortSummaryExtensionTests.cs
@@ -0,0 +1,31 @@
+using NUnit.Framework;
+using SFA.DAS.CommitmentsV2.Types;
+using SFA.DAS.EmployerAccounts.Web.Extensions;
+
+namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Extensions
+{
+ [TestFixture]
+ public class CohortSummaryExtensionTests
+ {
+ [TestCase(false, Party.Employer, CohortStatus.Review)]
+ [TestCase(true, Party.Employer, CohortStatus.Draft)]
+ [TestCase(false, Party.Provider, CohortStatus.WithTrainingProvider)]
+ [TestCase(true, Party.Provider, CohortStatus.Unknown)]
+ public void CohortSummary_GetStatus_Returns_Correct_Status(bool isDraft, Party withParty, CohortStatus cohortStatus)
+ {
+ //Arrange
+ var cohortSummary = new CohortSummary
+ {
+ CohortId = 1,
+ IsDraft = isDraft,
+ WithParty = withParty
+ };
+
+ //Act
+ var status = cohortSummary.GetStatus();
+
+ //Assert
+ Assert.AreEqual(cohortStatus, status);
+ }
+ }
+}
diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Mappings/WhenAutoMapping.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Mappings/WhenAutoMapping.cs
index ff3b1a71b6..5b892b4582 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Mappings/WhenAutoMapping.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Mappings/WhenAutoMapping.cs
@@ -22,6 +22,7 @@ public void ThenShouldUseValidConfiguration()
c.AddProfile();
c.AddProfile();
c.AddProfile();
+ c.AddProfile();
});
config.AssertConfigurationIsValid();
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 555a63c34f..6fb012bf81 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingAccount.cs
@@ -1,4 +1,5 @@
-using System;
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -6,10 +7,7 @@
using MediatR;
using Moq;
using NUnit.Framework;
-using SFA.DAS.Authorization;
using SFA.DAS.Authorization.Services;
-using SFA.DAS.CommitmentsV2.Api.Client;
-using SFA.DAS.Common.Domain.Types;
using SFA.DAS.EAS.Account.Api.Client;
using SFA.DAS.EAS.Account.Api.Types;
using SFA.DAS.EmployerAccounts.Dtos;
@@ -18,7 +16,9 @@
using SFA.DAS.EmployerAccounts.Models.Account;
using SFA.DAS.EmployerAccounts.Models.AccountTeam;
using SFA.DAS.EmployerAccounts.Models.Recruit;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
using SFA.DAS.EmployerAccounts.Models.Reservations;
+using SFA.DAS.EmployerAccounts.Queries.GetSingleCohort;
using SFA.DAS.EmployerAccounts.Queries.GetAccountEmployerAgreements;
using SFA.DAS.EmployerAccounts.Queries.GetAccountStats;
using SFA.DAS.EmployerAccounts.Queries.GetAccountTasks;
@@ -26,9 +26,11 @@
using SFA.DAS.EmployerAccounts.Queries.GetReservations;
using SFA.DAS.EmployerAccounts.Queries.GetTeamUser;
using SFA.DAS.EmployerAccounts.Queries.GetUserAccountRole;
+using SFA.DAS.EmployerAccounts.Web.Extensions;
using SFA.DAS.EmployerAccounts.Queries.GetVacancies;
using SFA.DAS.EmployerAccounts.Web.Orchestrators;
using SFA.DAS.EmployerAccounts.Web.ViewModels;
+using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship;
namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrchestratorTests
{
@@ -39,11 +41,10 @@ public class WhenGettingAccount
private const string UserId = "USER1";
private Mock _mediator;
- private EmployerTeamOrchestrator _orchestrator;
+ private EmployerTeamOrchestrator _orchestrator;
private AccountStats _accountStats;
private Mock _currentDateTime;
private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
private Mock _mapper;
private List _tasks;
private AccountTask _testTask;
@@ -142,29 +143,64 @@ public void Arrange()
_mediator.Setup(x => x.SendAsync(It.IsAny()))
.ReturnsAsync(new GetAccountStatsResponse {Stats = _accountStats});
+
_mediator.Setup(m => m.SendAsync(It.Is(q => q.HashedAccountId == HashedAccountId)))
- .ReturnsAsync(new GetReservationsResponse
- {
- Reservations = new List
- {
+ .ReturnsAsync(new GetReservationsResponse
+ {
+ Reservations = new List
+ {
new Reservation
{
AccountId = 123
}
+ }
+ });
+
+ _mediator.Setup(m => m.SendAsync(It.Is(q => q.HashedAccountId == HashedAccountId)))
+ .ReturnsAsync(new GetApprenticeshipsResponse
+ {
+ Apprenticeships = new List
+ {
+ new Apprenticeship { FirstName = "FirstName" }
+ }
+ });
+
+
+ var Cohort = new Cohort()
+ {
+ Id = 1,
+ CohortStatus = EmployerAccounts.Models.CommitmentsV2.CohortStatus.WithTrainingProvider,
+ NumberOfDraftApprentices = 1,
+ Apprenticeships = new List
+ {
+ new Apprenticeship()
+ {
+ Id = 2,
+ FirstName = "FirstName",
+ LastName = "LastName",
+ CourseStartDate = new DateTime(2020,5,1),
+ CourseEndDate = new DateTime(2022,1,1),
+ CourseName = "CourseName"
+ }
}
+ };
+ _mediator.Setup(x => x.SendAsync(It.IsAny()))
+ .ReturnsAsync(new GetSingleCohortResponse
+ {
+ Cohort = Cohort
+
});
_currentDateTime = new Mock();
_accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
_accountApiClient.Setup(c => c.GetAccount(HashedAccountId)).ReturnsAsync(new AccountDetailViewModel
{ApprenticeshipEmployerType = "Levy"});
-
+
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _currentDateTime.Object, _accountApiClient.Object, _mapper.Object, Mock.Of());
}
[Test]
@@ -180,16 +216,6 @@ public async Task ThenShouldGetAccountStats()
Assert.AreEqual(_accountStats.TeamMemberCount, actual.Data.TeamMemberCount);
}
- [Test]
- public async Task ThenShouldGetReservationsCount()
- {
- // Act
- var actual = await _orchestrator.GetAccount(HashedAccountId, UserId);
-
- //Assert
- Assert.AreEqual(1, actual.Data.CallToActionViewModel.ReservationsCount);
- }
-
[Test]
public async Task ThenShouldReturnTasks()
{
@@ -308,9 +334,9 @@ public async Task ThenAgreementsAreRetrievedCorrectly()
Assert.AreEqual(4, actual.Data.RequiresAgreementSigning);
}
- [TestCase(ApprenticeshipEmployerType.Levy, "Levy")]
- [TestCase(ApprenticeshipEmployerType.NonLevy, "NonLevy")]
- public async Task ThenShouldReturnCorrectApprenticeshipEmployerTypeFromAccountApi(ApprenticeshipEmployerType expectedApprenticeshipEmployerType, string apiApprenticeshipEmployerType)
+ [TestCase(Common.Domain.Types.ApprenticeshipEmployerType.Levy, "Levy")]
+ [TestCase(Common.Domain.Types.ApprenticeshipEmployerType.NonLevy, "NonLevy")]
+ public async Task ThenShouldReturnCorrectApprenticeshipEmployerTypeFromAccountApi(Common.Domain.Types.ApprenticeshipEmployerType expectedApprenticeshipEmployerType, string apiApprenticeshipEmployerType)
{
//Arrange
_accountApiClient
@@ -331,5 +357,52 @@ public async Task ThenReturnAccountSummary()
var model = await _orchestrator.GetAccountSummary(HashedAccountId, UserId);
Assert.IsNotNull(model.Data);
}
+
+ [Test]
+ public async Task ThenShouldGetReservationsCount()
+ {
+ // Act
+ var result = await _orchestrator.GetAccount(HashedAccountId, UserId);
+
+ //Assert
+ Assert.AreEqual(1, result.Data.CallToActionViewModel.ReservationsCount);
+ }
+
+ [Test]
+ public async Task ThenShouldGetApprenticeshipResponse()
+ {
+ //Arrange
+ var apprenticeships = new List { new Apprenticeship { FirstName = "FirstName" } };
+ _mediator.Setup(m => m.SendAsync(It.Is(q => q.HashedAccountId == HashedAccountId)))
+ .ReturnsAsync(new GetApprenticeshipsResponse { Apprenticeships = apprenticeships });
+ var expectedApprenticeship = new List() {new ApprenticeshipViewModel { ApprenticeshipFullName = "FullName" }};
+ _mapper.Setup(m => m.Map, IEnumerable>(apprenticeships)).Returns(expectedApprenticeship);
+
+ //Act
+ var result = await _orchestrator.GetAccount(HashedAccountId, UserId);
+
+ //Assert
+ Assert.IsTrue(result.Data.CallToActionViewModel.Apprenticeships.Count().Equals(1));
+ }
+
+ [Test]
+ public async Task ThenShouldGetCohortResponse()
+ {
+ //Arrange
+ var Cohort = new Cohort() { Id = 1, NumberOfDraftApprentices = 1, Apprenticeships = new List { new Apprenticeship { FirstName = "FirstName" } } };
+ _mediator.Setup(x => x.SendAsync(It.IsAny())).ReturnsAsync(new GetSingleCohortResponse { Cohort = Cohort });
+ var expectedCohort = new CohortViewModel()
+ {
+ NumberOfDraftApprentices = 1,
+ Apprenticeships = new List { new ApprenticeshipViewModel { ApprenticeshipFullName = "FullName" } }
+ };
+ _mapper.Setup(m => m.Map(Cohort)).Returns(expectedCohort);
+
+ //Act
+ var result = await _orchestrator.GetAccount(HashedAccountId, UserId);
+
+ //Assert
+ Assert.AreEqual(1, result.Data.CallToActionViewModel.CohortsCount);
+ }
}
}
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 6b33fb79fc..2519d4bf19 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIChangeATeamMemberRole.cs
@@ -22,8 +22,7 @@ namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrche
class WhenIChangeATeamMemberRole
{
private Mock _mediator;
- private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
+ private Mock _accountApiClient;
private Mock _mapper;
private EmployerTeamOrchestrator _orchestrator;
@@ -31,11 +30,10 @@ class WhenIChangeATeamMemberRole
public void Arrange()
{
_mediator = new Mock();
- _accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
+ _accountApiClient = new Mock();
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _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 aab643d671..7e607c9ae6 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetATeamMembersDetails.cs
@@ -23,8 +23,7 @@ class WhenIGetATeamMembersDetails
private const string HashedAccountId = "ABC123";
private Mock _mediator;
- private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
+ private Mock _accountApiClient;
private Mock _mapper;
private EmployerTeamOrchestrator _orchestrator;
private GetMemberResponse _teamMemberResponse;
@@ -43,11 +42,10 @@ public void Arrange()
};
_mediator = new Mock();
- _accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
+ _accountApiClient = new Mock();
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _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 af3ada2128..fb66303035 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIGetMyTeamMembers.cs
@@ -17,8 +17,8 @@ namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrche
public class WhenIGetMyTeamMembers
{
private Mock _mediator;
- private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
+ private Mock _accountApiClient;
+
private Mock _mapper;
private EmployerTeamOrchestrator _orchestrator;
@@ -34,11 +34,10 @@ public void Arrange()
TeamMembers = new List {new TeamMember()}
});
- _accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
+ _accountApiClient = new Mock();
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _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 083c7cac74..6c321417c3 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIInviteATeamMember.cs
@@ -23,8 +23,8 @@ namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrche
class WhenIInviteATeamMember
{
private Mock _mediator;
- private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
+ private Mock _accountApiClient;
+
private Mock _mapper;
private EmployerTeamOrchestrator _orchestrator;
@@ -33,10 +33,9 @@ class WhenIInviteATeamMember
public void Arrange()
{
_mediator = new Mock();
- _accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
+ _accountApiClient = new Mock();
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _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 d8cda9df19..5bc11341f2 100644
--- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenIRemoveATeamMember.cs
@@ -25,8 +25,7 @@ class WhenIRemoveATeamMember
const string Email = "test@test.com";
private Mock _mediator;
- private Mock _accountApiClient;
- private Mock _commitmentsApiClient;
+ private Mock _accountApiClient;
private Mock _mapper;
private EmployerTeamOrchestrator _orchestrator;
@@ -35,11 +34,10 @@ class WhenIRemoveATeamMember
public void Arrange()
{
_mediator = new Mock();
- _accountApiClient = new Mock();
- _commitmentsApiClient = new Mock();
+ _accountApiClient = new Mock();
_mapper = new Mock();
- _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, Mock.Of(), _accountApiClient.Object, _commitmentsApiClient.Object, _mapper.Object, Mock.Of());
+ _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/Controllers/EmployerTeamController.cs b/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerTeamController.cs
index e8b585cdca..59509e59af 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerTeamController.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Controllers/EmployerTeamController.cs
@@ -1,19 +1,20 @@
-using System;
-using System.Linq;
-using System.Net;
-using System.Threading.Tasks;
-using System.Web;
-using System.Web.Mvc;
-using SFA.DAS.Authentication;
+using SFA.DAS.Authentication;
+using SFA.DAS.Authorization.Mvc.Attributes;
+using SFA.DAS.Authorization.Services;
using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models;
using SFA.DAS.EmployerAccounts.Web.Extensions;
using SFA.DAS.EmployerAccounts.Web.Helpers;
using SFA.DAS.EmployerAccounts.Web.Orchestrators;
using SFA.DAS.EmployerAccounts.Web.ViewModels;
using SFA.DAS.Validation;
-using SFA.DAS.Authorization.Mvc.Attributes;
-using SFA.DAS.Authorization.Services;
-using SFA.DAS.EmployerAccounts.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Threading.Tasks;
+using System.Web;
+using System.Web.Mvc;
namespace SFA.DAS.EmployerAccounts.Web.Controllers
{
@@ -28,7 +29,7 @@ public EmployerTeamController(
IAuthenticationService owinWrapper)
: base(owinWrapper)
{
- _employerTeamOrchestrator = null;
+ _employerTeamOrchestrator = null;
}
public EmployerTeamController(
@@ -334,6 +335,45 @@ public ActionResult ContinueSetupCreateAdvert(string hashedAccountId, bool? requ
return Redirect(Url.EmployerCommitmentsAction("apprentices/inform"));
}
+ [ChildActionOnly]
+ public ActionResult SingleApprenticeshipContinueSetup(AccountDashboardViewModel model)
+ {
+ return PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single());
+ }
+
+ [ChildActionOnly]
+ public ActionResult SingleApprenticeshipWithTrainingProvider(AccountDashboardViewModel model)
+ {
+ return PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single());
+ }
+
+ [ChildActionOnly]
+ public ActionResult SingleApprenticeshipReadyForReview(AccountDashboardViewModel model)
+ {
+ return PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single());
+ }
+
+ [ChildActionOnly]
+ public ActionResult SingleApprenticeshipApproved(AccountDashboardViewModel model)
+ {
+ return PartialView(model.CallToActionViewModel.Apprenticeships.First());
+ }
+
+ [ChildActionOnly]
+ public ActionResult SingleApprenticeshipContinueWithProvider(AccountDashboardViewModel model)
+ {
+ model.CallToActionViewModel.Cohorts.Single().Apprenticeships = new List()
+ {
+ new ApprenticeshipViewModel()
+ {
+ CourseName = model.CallToActionViewModel.Reservations?.Single().Course?.CourseDescription,
+ HashedCohortId = model.CallToActionViewModel.Cohorts?.Single().HashedCohortId,
+ TrainingProvider = model.CallToActionViewModel.Cohorts?.Single().TrainingProvider.First()
+ }
+ };
+ return PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single());
+ }
+
[ChildActionOnly]
public override ActionResult SupportUserBanner(IAccountIdentifier model = null)
{
@@ -354,10 +394,10 @@ public override ActionResult SupportUserBanner(IAccountIdentifier model = null)
public ActionResult Row1Panel1(AccountDashboardViewModel model)
{
var viewModel = new PanelViewModel { ViewName = "Empty", Data = model };
-
+
if (model.PayeSchemeCount == 0)
{
- viewModel.ViewName = "AddPAYE";
+ viewModel.ViewName = "AddPAYE";
}
else if (_authorizationService.IsAuthorized("EmployerFeature.CallToAction"))
{
@@ -494,7 +534,7 @@ public ActionResult CheckFunding(AccountDashboardViewModel model)
public ActionResult ContinueSetupForSingleReservation(AccountDashboardViewModel model)
{
var reservation = model.CallToActionViewModel.Reservations?.FirstOrDefault();
- var viewModel = new ReservationViewModel(reservation);
+ var viewModel = new ReservationViewModel(reservation);
return PartialView(viewModel);
}
@@ -575,6 +615,7 @@ public ActionResult OtherTasksPanel(AccountDashboardViewModel model)
{
return PartialView(model);
}
+
private async Task> GetAccountInformation(string hashedAccountId)
{
diff --git a/src/SFA.DAS.EmployerAccounts.Web/DependencyResolution/IoC.cs b/src/SFA.DAS.EmployerAccounts.Web/DependencyResolution/IoC.cs
index afee9b47c2..3f84a37b78 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/DependencyResolution/IoC.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/DependencyResolution/IoC.cs
@@ -1,15 +1,15 @@
-using SFA.DAS.EmployerAccounts.Api.Client;
-using SFA.DAS.EmployerAccounts.Data;
using SFA.DAS.Activities.Client;
using SFA.DAS.Authorization.DependencyResolution.StructureMap;
using SFA.DAS.Authorization.EmployerFeatures.DependencyResolution.StructureMap;
using SFA.DAS.Authorization.EmployerUserRoles.DependencyResolution.StructureMap;
+using SFA.DAS.EmployerAccounts.Api.Client;
+using SFA.DAS.EmployerAccounts.Data;
using SFA.DAS.EmployerAccounts.DependencyResolution;
-using StructureMap;
-using ConfigurationRegistry = SFA.DAS.EmployerAccounts.DependencyResolution.ConfigurationRegistry;
+using SFA.DAS.UnitOfWork.EntityFramework.StructureMap;
+using SFA.DAS.UnitOfWork.NServiceBus.DependencyResolution.StructureMap;
using SFA.DAS.UnitOfWork.NServiceBus.Features.ClientOutbox.DependencyResolution.StructureMap;
-using SFA.DAS.UnitOfWork.NServiceBus.DependencyResolution.StructureMap;
-using SFA.DAS.UnitOfWork.EntityFramework.StructureMap;
+using StructureMap;
+using ConfigurationRegistry = SFA.DAS.EmployerAccounts.DependencyResolution.ConfigurationRegistry;
namespace SFA.DAS.EmployerAccounts.Web.DependencyResolution
{
@@ -53,7 +53,8 @@ public static IContainer Initialize()
c.AddRegistry();
c.AddRegistry();
c.AddRegistry();
- c.AddRegistry();
+ c.AddRegistry();
+ c.AddRegistry();
c.AddRegistry();
});
}
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Extensions/CohortSummaryExtension.cs b/src/SFA.DAS.EmployerAccounts.Web/Extensions/CohortSummaryExtension.cs
index 1adefe6eb3..8ff2ea2b83 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Extensions/CohortSummaryExtension.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Extensions/CohortSummaryExtension.cs
@@ -11,7 +11,7 @@ public static CohortStatus GetStatus(this CohortSummary cohort)
else if (!cohort.IsDraft && cohort.WithParty == Party.Employer)
return CohortStatus.Review;
else if (!cohort.IsDraft && cohort.WithParty == Party.Provider)
- return CohortStatus.WithProvider;
+ return CohortStatus.WithTrainingProvider;
else if (!cohort.IsDraft && cohort.WithParty == Party.TransferSender)
return CohortStatus.WithTransferSender;
else
@@ -24,7 +24,7 @@ public enum CohortStatus
Unknown,
Draft,
Review,
- WithProvider,
+ WithTrainingProvider,
WithTransferSender
}
}
\ No newline at end of file
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Extensions/HtmlHelperExtensions.cs b/src/SFA.DAS.EmployerAccounts.Web/Extensions/HtmlHelperExtensions.cs
index 1af75f0b14..d378469a84 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Extensions/HtmlHelperExtensions.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Extensions/HtmlHelperExtensions.cs
@@ -1,12 +1,13 @@
using SFA.DAS.EmployerAccounts.Configuration;
+using SFA.DAS.EmployerAccounts.Web.Helpers;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+using SFA.DAS.MA.Shared.UI.Configuration;
+using SFA.DAS.MA.Shared.UI.Models;
+using SFA.DAS.MA.Shared.UI.Models.Links;
using System;
using System.Linq;
using System.Security.Claims;
using System.Web.Mvc;
-using SFA.DAS.EmployerAccounts.Web.Helpers;
-using SFA.DAS.MA.Shared.UI.Models;
-using SFA.DAS.MA.Shared.UI.Configuration;
-using SFA.DAS.MA.Shared.UI.Models.Links;
namespace SFA.DAS.EmployerAccounts.Web.Extensions
{
@@ -24,7 +25,7 @@ public static MvcHtmlString CommaSeperatedAddressToHtml(this HtmlHelper htmlHelp
{
var htmlAddress = commaSeperatedAddress.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(line => $"{line.Trim()}
")
- .Aggregate("", (x, y) => x + y);
+ .Aggregate(string.Empty, (x, y) => x + y);
return new MvcHtmlString(htmlAddress);
}
@@ -127,5 +128,4 @@ public static IFooterViewModel GetFooterViewModel(this HtmlHelper html, bool use
);
}
}
-
}
\ No newline at end of file
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Extensions/UrlHelperExtensions.cs b/src/SFA.DAS.EmployerAccounts.Web/Extensions/UrlHelperExtensions.cs
index 309af12254..7aca99dbd4 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Extensions/UrlHelperExtensions.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Extensions/UrlHelperExtensions.cs
@@ -18,7 +18,7 @@ public static string EmployerCommitmentsAction(this UrlHelper helper, string pat
{
var configuration = DependencyResolver.Current.GetService();
var baseUrl = configuration.EmployerCommitmentsBaseUrl;
-
+
return AccountAction(helper, baseUrl, path);
}
@@ -26,10 +26,8 @@ public static string EmployerCommitmentsV2Action(this UrlHelper helper, string p
{
var configuration = DependencyResolver.Current.GetService();
var baseUrl = configuration.EmployerCommitmentsV2BaseUrl;
- var hashedAccountId = helper.RequestContext.RouteData.Values[ControllerConstants.AccountHashedIdRouteKeyName];
- var accountPath = hashedAccountId == null ? $"{path}" : $"{hashedAccountId}/{path}";
- return Action(baseUrl, accountPath);
+ return CommitmentAction(helper, baseUrl, path);
}
public static string ReservationsAction(this UrlHelper helper, string path)
@@ -60,7 +58,7 @@ public static string EmployerRecruitAction(this UrlHelper helper, string path =
{
var configuration = DependencyResolver.Current.GetService();
var baseUrl = configuration.EmployerRecruitBaseUrl;
-
+
return AccountAction(helper, baseUrl, path);
}
@@ -104,6 +102,14 @@ private static string AccountAction(UrlHelper helper, string baseUrl, string pat
return Action(baseUrl, accountPath);
}
+ private static string CommitmentAction(UrlHelper helper, string baseUrl, string path)
+ {
+ var hashedAccountId = helper.RequestContext.RouteData.Values[ControllerConstants.AccountHashedIdRouteKeyName];
+ var commitmentPath = hashedAccountId == null ? $"{path}" : $"{hashedAccountId}/{path}";
+
+ return Action(baseUrl, commitmentPath);
+ }
+
private static string Action(string baseUrl, string path)
{
var trimmedBaseUrl = baseUrl?.TrimEnd('/') ?? string.Empty;
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs b/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs
index 2e23c02df4..66351a5189 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Helpers/ControllerConstants.cs
@@ -85,6 +85,10 @@ public static class ControllerConstants
public const string Settings = "Settings";
public const string Details = "Details";
public const string CookieConsent = "CookieConsent";
- public const string Tier2UserClaim = "Tier2User";
+ public const string Tier2UserClaim = "Tier2User";
+ public const string EditApprentice = "EditApprentice";
+ public const string ViewApprentice = "ViewApprentice";
+ public const string ApproveOrRejectApprentice = "ApproveOrRejectApprentice";
+ public const string ViewApprenticeBeforeApprove = "ViewApprenticeBeforeApprove";
}
}
\ No newline at end of file
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Mappings/CohortMapping.cs b/src/SFA.DAS.EmployerAccounts.Web/Mappings/CohortMapping.cs
new file mode 100644
index 0000000000..c18bf23558
--- /dev/null
+++ b/src/SFA.DAS.EmployerAccounts.Web/Mappings/CohortMapping.cs
@@ -0,0 +1,27 @@
+using AutoMapper;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Web.ViewModels;
+
+namespace SFA.DAS.EmployerAccounts.Web.Mappings
+{
+ public class CohortMapping : Profile
+ {
+ public CohortMapping()
+ {
+ CreateMap()
+ .ForMember(dest => dest.HashedCohortId, opt => opt.MapFrom(src => src.HashedId));
+
+ CreateMap()
+ .ForMember(dest => dest.ApprenticeshipFullName, opt => opt.MapFrom(src => string.Format("{0} {1}",
+ src.FirstName, src.LastName)))
+ .ForMember(dest => dest.HashedApprenticeshipId, opt => opt.MapFrom(src => src.HashedId))
+ .ForMember(dest => dest.CohortId, opt => opt.MapFrom(src => src.Cohort.Id))
+ .ForMember(dest => dest.HashedCohortId, opt => opt.MapFrom(src => src.Cohort.HashedId))
+ .ForMember(dest => dest.NumberOfDraftApprentices, opt => opt.MapFrom(src => src.Cohort.NumberOfDraftApprentices))
+ .ForMember(dest => dest.CourseStartDateText, opt => opt.MapFrom(src => src.CourseStartDate.HasValue ? src.CourseStartDate.Value.ToString("dd MMMM yyyy") : ""))
+ .ForMember(dest => dest.CourseEndDateText, opt => opt.MapFrom(src => src.CourseEndDate.HasValue ? src.CourseEndDate.Value.ToString("dd MMMM yyyy") : ""));
+
+ CreateMap();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Models/TrainingDateModel.cs b/src/SFA.DAS.EmployerAccounts.Web/Models/TrainingDateModel.cs
index 6893b449d3..42149f07e8 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Models/TrainingDateModel.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Models/TrainingDateModel.cs
@@ -11,7 +11,7 @@ public override string ToString()
{
return EndDate == default(DateTime) ?
$"{StartDate:MMMM yyyy}" :
- $"{StartDate:MMMM yyyy} to {EndDate:MMMM yyyy}";
+ $"Between {StartDate:MMMM yyyy} and {EndDate:MMMM yyyy}";
}
public override bool Equals(object obj)
diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs
index 3513cc95e3..46d351e57c 100644
--- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs
+++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs
@@ -1,6 +1,6 @@
using AutoMapper;
using MediatR;
-using SFA.DAS.Common.Domain.Types;
+using SFA.DAS.Authorization.Services;
using SFA.DAS.EAS.Account.Api.Client;
using SFA.DAS.EAS.Account.Api.Types;
using SFA.DAS.EmployerAccounts.Commands.ChangeTeamMemberRole;
@@ -10,19 +10,22 @@
using SFA.DAS.EmployerAccounts.Commands.ResendInvitation;
using SFA.DAS.EmployerAccounts.Commands.UpdateShowWizard;
using SFA.DAS.EmployerAccounts.Interfaces;
+using SFA.DAS.EmployerAccounts.Models;
using SFA.DAS.EmployerAccounts.Models.Account;
using SFA.DAS.EmployerAccounts.Models.AccountTeam;
+using SFA.DAS.EmployerAccounts.Models.CommitmentsV2;
+using SFA.DAS.EmployerAccounts.Queries.GetSingleCohort;
using SFA.DAS.EmployerAccounts.Queries.GetAccountEmployerAgreements;
using SFA.DAS.EmployerAccounts.Queries.GetAccountStats;
-using SFA.DAS.EmployerAccounts.Queries.GetAccountTasks;
+using SFA.DAS.EmployerAccounts.Queries.GetAccountTasks;
using SFA.DAS.EmployerAccounts.Queries.GetAccountTeamMembers;
+using SFA.DAS.EmployerAccounts.Queries.GetApprenticeship;
using SFA.DAS.EmployerAccounts.Queries.GetEmployerAccount;
using SFA.DAS.EmployerAccounts.Queries.GetInvitation;
using SFA.DAS.EmployerAccounts.Queries.GetMember;
using SFA.DAS.EmployerAccounts.Queries.GetReservations;
using SFA.DAS.EmployerAccounts.Queries.GetTeamUser;
using SFA.DAS.EmployerAccounts.Queries.GetUser;
-using SFA.DAS.EmployerAccounts.Web.Exceptions;
using SFA.DAS.EmployerAccounts.Web.ViewModels;
using SFA.DAS.Validation;
using System;
@@ -35,6 +38,8 @@
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.EmployerAccounts.Queries.GetVacancies;
using SFA.DAS.EmployerAccounts.Models.Recruit;
+using ResourceNotFoundException = SFA.DAS.EmployerAccounts.Web.Exceptions.ResourceNotFoundException;
+using SFA.DAS.Common.Domain.Types;
namespace SFA.DAS.EmployerAccounts.Web.Orchestrators
{
@@ -42,23 +47,20 @@ public class EmployerTeamOrchestrator : UserVerificationOrchestratorBase
{
private readonly IMediator _mediator;
private readonly ICurrentDateTime _currentDateTime;
- private readonly IAccountApiClient _accountApiClient;
- private readonly ICommitmentsApiClient _commitmentsApiClient;
+ private readonly IAccountApiClient _accountApiClient;
private readonly IMapper _mapper;
private readonly IAuthorizationService _authorizationService;
- public EmployerTeamOrchestrator(IMediator mediator,
- ICurrentDateTime currentDateTime,
- IAccountApiClient accountApiClient,
- ICommitmentsApiClient commitmentsApiClient,
- IMapper mapper,
+ public EmployerTeamOrchestrator(IMediator mediator,
+ ICurrentDateTime currentDateTime,
+ IAccountApiClient accountApiClient,
+ IMapper mapper,
IAuthorizationService authorizationService)
: base(mediator)
{
_mediator = mediator;
_currentDateTime = currentDateTime;
- _accountApiClient = accountApiClient;
- _commitmentsApiClient = commitmentsApiClient;
+ _accountApiClient = accountApiClient;
_mapper = mapper;
_authorizationService = authorizationService;
}
@@ -70,8 +72,8 @@ protected EmployerTeamOrchestrator()
public async Task> Cancel(string email, string hashedAccountId, string externalUserId)
{
- var response = await GetTeamMembers(hashedAccountId, externalUserId);
-
+ var response = await GetTeamMembers(hashedAccountId, externalUserId);
+
if (response.Status != HttpStatusCode.OK)
{
return response;
@@ -177,22 +179,33 @@ public virtual async Task> GetAc
});
var accountStatsResponseTask = _mediator.SendAsync(new GetAccountStatsQuery
- {
- HashedAccountId = hashedAccountId,
- ExternalUserId = externalUserId
- });
-
- var agreementsResponseTask = _mediator.SendAsync(new GetAccountEmployerAgreementsRequest
{
HashedAccountId = hashedAccountId,
ExternalUserId = externalUserId
});
-
- var reservationsResponseTask = _mediator.SendAsync(new GetReservationsRequest
- {
- HashedAccountId = hashedAccountId,
- ExternalUserId = externalUserId
+ var agreementsResponseTask = _mediator.SendAsync(new GetAccountEmployerAgreementsRequest
+ {
+ HashedAccountId = hashedAccountId,
+ ExternalUserId = externalUserId
+ });
+
+ var reservationsResponseTask = _mediator.SendAsync(new GetReservationsRequest
+ {
+ HashedAccountId = hashedAccountId,
+ ExternalUserId = externalUserId
+ });
+
+ var apprenticeshipsResponseTask = _mediator.SendAsync(new GetApprenticeshipsRequest
+ {
+ HashedAccountId = hashedAccountId,
+ ExternalUserId = externalUserId
+ });
+
+ var accountCohortResponseTask = _mediator.SendAsync(new GetSingleCohortRequest
+ {
+ HashedAccountId = hashedAccountId,
+ ExternalUserId = externalUserId
});
var vacanciesResponseTask = _mediator.SendAsync(new GetVacanciesRequest
@@ -201,18 +214,20 @@ public virtual async Task> GetAc
ExternalUserId = externalUserId
});
- await Task.WhenAll(apiGetAccountTask, accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask, reservationsResponseTask, vacanciesResponseTask).ConfigureAwait(false);
-
- var accountResponse = accountResponseTask.Result;
- var userRoleResponse = userRoleResponseTask.Result;
- var userResponse = userResponseTask.Result;
- var accountStatsResponse = accountStatsResponseTask.Result;
- var agreementsResponse = agreementsResponseTask.Result;
- var reservationsResponse = reservationsResponseTask.Result;
+ await Task.WhenAll(apiGetAccountTask, accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask, reservationsResponseTask, apprenticeshipsResponseTask, accountCohortResponseTask, vacanciesResponseTask).ConfigureAwait(false);
+
+ var accountResponse = accountResponseTask.Result;
+ var userRoleResponse = userRoleResponseTask.Result;
+ var userResponse = userResponseTask.Result;
+ var accountStatsResponse = accountStatsResponseTask.Result;
+ var agreementsResponse = agreementsResponseTask.Result;
+ var reservationsResponse = reservationsResponseTask.Result;
var accountDetailViewModel = apiGetAccountTask.Result;
var vacanciesResponse = vacanciesResponseTask.Result;
+ var accountCohort = accountCohortResponseTask.Result;
+ var apprenticeshipsResponse = apprenticeshipsResponseTask.Result;
- var apprenticeshipEmployerType = (ApprenticeshipEmployerType)Enum.Parse(typeof(ApprenticeshipEmployerType), accountDetailViewModel.ApprenticeshipEmployerType, true);
+ var apprenticeshipEmployerType = (Common.Domain.Types.ApprenticeshipEmployerType)Enum.Parse(typeof(Common.Domain.Types.ApprenticeshipEmployerType), accountDetailViewModel.ApprenticeshipEmployerType, true);
var tasksResponse = await _mediator.SendAsync(new GetAccountTasksQuery
{
@@ -253,6 +268,11 @@ public virtual async Task> GetAc
VacancyCount = vacanciesResponse.Vacancies.Count(),
Vacancies = _mapper.Map, IEnumerable>(vacanciesResponse.Vacancies)
},
+ Apprenticeships = _mapper.Map, IEnumerable>(apprenticeshipsResponse?.Apprenticeships),
+ Cohorts = new List
+ {
+ _mapper.Map(accountCohort.Cohort)
+ },
UnableToDetermineCallToAction = vacanciesResponse.HasFailed || reservationsResponse.HasFailed
}
};
@@ -261,7 +281,7 @@ public virtual async Task> GetAc
// we could blat over the existing flag, but it's much nicer to store the enum (as above) rather than a byte!
//viewModel.Account.ApprenticeshipEmployerType = (byte) ((ApprenticeshipEmployerType) Enum.Parse(typeof(ApprenticeshipEmployerType), apiGetAccountTask.Result.ApprenticeshipEmployerType, true));
- return new OrchestratorResponse
+ return new OrchestratorResponse
{
Status = HttpStatusCode.OK,
Data = viewModel
@@ -291,8 +311,8 @@ public virtual async Task> GetAc
Exception = ex
};
}
- }
-
+ }
+
public async Task> GetInvitation(string id)
{
var invitationResponse = await _mediator.SendAsync(new GetInvitationRequest
@@ -655,6 +675,11 @@ public void GetCallToActionViewName(PanelViewModel vi
if (viewModel.Data.ApprenticeshipEmployerType == ApprenticeshipEmployerType.NonLevy)
{
+ rules.Add(120, EvaluateSingleApprenticeshipCallToActionRule);
+ rules.Add(121, EvaluateSingleApprenticeshipDraftStatusCallToActionRule);
+ rules.Add(122, EvaluateSingleApprenticeshipsWithTrainingProviderStatusCallToActionRule);
+ rules.Add(123, EvaluateSingleApprenticeshipsWithReadyToReviewStatusCallToActionRule);
+ rules.Add(124, EvaluateContinueSetupForSingleApprenticeshipByProviderCallToActionRule);
rules.Add(200, EvalutateSingleReservationCallToActionRule);
rules.Add(201, EvalutateHasReservationsCallToActionRule);
@@ -799,5 +824,89 @@ private bool EvalutateHasReservationsCallToActionRule(PanelViewModel viewModel)
+ {
+ if (viewModel.Data.CallToActionViewModel.ReservationsCount == 1
+ && viewModel.Data.CallToActionViewModel?.ApprenticeshipsCount == 1)
+ {
+ viewModel.ViewName = "SingleApprenticeshipApproved";
+ viewModel.PanelType = PanelType.Summary;
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool EvaluateSingleApprenticeshipDraftStatusCallToActionRule(PanelViewModel viewModel)
+ {
+ if (viewModel.Data.CallToActionViewModel.ReservationsCount == 1
+ && viewModel.Data.CallToActionViewModel.CohortsCount == 1
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single() != null
+ && viewModel.Data.CallToActionViewModel.ApprenticeshipsCount == 0
+ && viewModel.Data.CallToActionViewModel.Cohorts?.Single().CohortApprenticeshipsCount == 1
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single().HasSingleDraftApprenticeship.Equals(true)
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single().CohortStatus.Equals(CohortStatus.Draft))
+ {
+ viewModel.ViewName = "SingleApprenticeshipContinueSetup";
+ viewModel.PanelType = PanelType.Summary;
+ return true;
+ }
+
+ return false;
+ }
+
+ private bool EvaluateSingleApprenticeshipsWithTrainingProviderStatusCallToActionRule(PanelViewModel viewModel)
+ {
+ if (viewModel.Data.CallToActionViewModel.ReservationsCount == 1
+ && viewModel.Data.CallToActionViewModel.CohortsCount == 1
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single() != null
+ && viewModel.Data.CallToActionViewModel.ApprenticeshipsCount == 0
+ && viewModel.Data.CallToActionViewModel.Cohorts?.Single().CohortApprenticeshipsCount == 1
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single().HasSingleDraftApprenticeship.Equals(true)
+ && viewModel.Data.CallToActionViewModel.Cohorts.Single().CohortStatus.Equals(CohortStatus.WithTrainingProvider))
+ {
+ viewModel.ViewName = "SingleApprenticeshipWithTrainingProvider";
+ viewModel.PanelType = PanelType.Summary;
+ return true;
+ }
+ return false;
+ }
+
+
+ private bool EvaluateContinueSetupForSingleApprenticeshipByProviderCallToActionRule(PanelViewModel