public void ThenForNonLevyContinueSetupForSingleApprenticeshipByProviderViewIsReturnedAtRow1Panel1() { //Arrange var model = new AccountDashboardViewModel() { PayeSchemeCount = 1, ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy, CallToActionViewModel = new CallToActionViewModel { Cohorts = new List <CohortViewModel> { new CohortViewModel { NumberOfDraftApprentices = 0, CohortStatus = CohortStatus.WithTrainingProvider, Apprenticeships = new List <ApprenticeshipViewModel>() { 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); }
public ActionResult ContinueSetupForSingleReservation(AccountDashboardViewModel model) { var reservation = model.CallToActionViewModel.Reservations?.FirstOrDefault(); var viewModel = new ReservationViewModel(reservation); return(PartialView(viewModel)); }
public void ThenForNonLevyTheContinueSetupForSingleReservationViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel() { PayeSchemeCount = 1, CallToActionViewModel = new CallToActionViewModel { Reservations = new List <Reservation> { 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); }
public void ThenForNonLevyWithASingleSubmittedVacancyTheVacancyPendingReviewViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 1, CallToActionViewModel = new CallToActionViewModel { Reservations = new List <EmployerAccounts.Models.Reservations.Reservation> { new EmployerAccounts.Models.Reservations.Reservation { Status = EmployerAccounts.Models.Reservations.ReservationStatus.Completed } }, VacanciesViewModel = new VacanciesViewModel { VacancyCount = 1, Vacancies = new List <VacancyViewModel> { new VacancyViewModel { Status = EmployerAccounts.Models.Recruit.VacancyStatus.Submitted } } } }, ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy }; //Act var result = _controller.Row1Panel1(model) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("VacancyPendingReview", (result.Model as dynamic).ViewName); }
public void ThenForNonLevyTheYourSingleApprovedApprenticeViewIsReturnedAtRow1Panel1() { //Arrange var model = new AccountDashboardViewModel() { PayeSchemeCount = 1, ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy, CallToActionViewModel = new CallToActionViewModel { Reservations = new List <Reservation> { new Reservation { Status = ReservationStatus.Completed } }, Apprenticeships = new List <ApprenticeshipViewModel>() { 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); }
public static bool ShowYourFundingReservationsLink(this AccountDashboardViewModel model) { if (model.ApprenticeshipEmployerType == ApprenticeshipEmployerType.NonLevy) { return(true); } return(false); }
public ActionResult Dashboard() { var defectsFixed = _userService.GetFixedCountForUser(User.Identity.Name); var defectsLogged = _userService.GetLoggedCountForUser(User.Identity.Name); var viewModel = new AccountDashboardViewModel { DefectsFixed = defectsFixed, DefectsLogged = defectsLogged }; return(View(viewModel)); }
public ActionResult SingleApprenticeshipContinueWithProvider(AccountDashboardViewModel model) { model.CallToActionViewModel.Cohorts.Single().Apprenticeships = new List <ApprenticeshipViewModel>() { new ApprenticeshipViewModel() { CourseName = model.CallToActionViewModel.Cohorts?.Single()?.CohortApprenticeshipsCount > 0 ? model.CallToActionViewModel.Cohorts?.Single()?.Apprenticeships?.Single()?.CourseName : string.Empty, HashedCohortId = model.CallToActionViewModel.Cohorts?.Single().HashedCohortId, TrainingProvider = model.CallToActionViewModel.Cohorts?.Single().TrainingProvider.First() } }; return(PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single())); }
public async Task <OrchestratorResponse <AccountDashboardViewModel> > GetAccount( string accountId, string externalUserId) { try { var accountResponse = await _mediator.SendAsync(new GetEmployerAccountHashedQuery { HashedAccountId = accountId, UserId = externalUserId }); var showSigningNotice = false; var userRoleResponse = await GetUserAccountRole(accountId, externalUserId); if (userRoleResponse.UserRole == Role.Owner || userRoleResponse.UserRole == Role.Transactor) { var agreementsResponse = await _mediator.SendAsync(new GetAccountEmployerAgreementsRequest { HashedAccountId = accountId, ExternalUserId = externalUserId }); showSigningNotice = agreementsResponse.EmployerAgreements.Any(a => a.Status == Domain.Models.EmployerAgreement.EmployerAgreementStatus.Pending); } var viewModel = new AccountDashboardViewModel { Account = accountResponse.Account, RequiresAgreementSigning = showSigningNotice }; return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.OK, Data = viewModel }); } catch (Exception ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.Unauthorized, Exception = ex }); } }
public void ThenTheAddPayeViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 0 }; //Act var result = _controller.Row1Panel1(model) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("AddPAYE", (result.Model as dynamic).ViewName); }
public void ThenForLevyTheEmptyViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 1, ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.Levy }; //Act var result = _controller.Row1Panel1(model) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("Empty", (result.Model as dynamic).ViewName); }
public ActionResult Row1Panel1(AccountDashboardViewModel model) { var viewModel = new PanelViewModel <AccountDashboardViewModel> { ViewName = "Empty", Data = model }; if (model.PayeSchemeCount == 0) { viewModel.ViewName = "AddPAYE"; } else { _employerTeamOrchestrator.GetCallToActionViewName(viewModel); } return(PartialView(viewModel)); }
public IActionResult Dashboard() { if (!HttpContext.Session.Keys.Contains("Account")) { RedirectToAction("Index", "Home"); } Account acc = GetAccountFromSession(); var model = new AccountDashboardViewModel { Account = _AccountLogic.GetSpecificAccount(acc) }; return(View(model)); }
public void ThenForNonLevyTheCheckFundingViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 1, CallToActionViewModel = new CallToActionViewModel(), ApprenticeshipEmployerType = Common.Domain.Types.ApprenticeshipEmployerType.NonLevy }; //Act var result = _controller.Row1Panel1(model) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("CheckFunding", (result.Model as dynamic).ViewName); Assert.AreEqual(PanelType.Action, (result.Model as dynamic).PanelType); }
public void ThenTheSignAgreementViewIsReturnedAtRow1Panel1() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 1, PendingAgreements = new List <PendingAgreementsViewModel> { new PendingAgreementsViewModel() } }; //Act var result = _controller.Row1Panel1(model) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("SignAgreement", (result.Model as dynamic).ViewName); }
public void IfIChooseYesIContinueTheJourney() { // Arrange var model = new AccountDashboardViewModel { PayeSchemeCount = 1, PendingAgreements = new List <PendingAgreementsViewModel> { new PendingAgreementsViewModel() } }; //Act var result = _controller.TriageApprenticeForExistingEmployee(new TriageViewModel { TriageOption = TriageOptions.No }) as ViewResult; //Assert Assert.AreEqual(ControllerConstants.TriageSetupApprenticeshipNewEmployeeViewName, result.ViewName); }
public void ShowYourFundingReservationsLink_GivenValues_ReturnsExpectedResult( ApprenticeshipEmployerType apprenticeshipEmployerType, AccountAgreementType agreementType, bool expectedValue) { // Arrange var model = new AccountDashboardViewModel { ApprenticeshipEmployerType = apprenticeshipEmployerType, AgreementInfo = new AgreementInfoViewModel { Type = agreementType } }; // Act var result = AccountDashboardViewModelExtensions.ShowYourFundingReservationsLink(model); // Assert Assert.AreEqual(expectedValue, result); }
public virtual async Task <OrchestratorResponse <AccountDashboardViewModel> > GetAccount(string hashedAccountId, string externalUserId) { try { var apiGetAccountTask = _accountApiClient.GetAccount(hashedAccountId); var accountResponseTask = _mediator.SendAsync(new GetEmployerAccountByHashedIdQuery { HashedAccountId = hashedAccountId, UserId = externalUserId }); var userRoleResponseTask = GetUserAccountRole(hashedAccountId, externalUserId); var userResponseTask = _mediator.SendAsync(new GetTeamMemberQuery { HashedAccountId = hashedAccountId, TeamMemberId = externalUserId }); var accountStatsResponseTask = _mediator.SendAsync(new GetAccountStatsQuery { HashedAccountId = hashedAccountId, ExternalUserId = externalUserId }); var agreementsResponseTask = _mediator.SendAsync(new GetAccountEmployerAgreementsRequest { HashedAccountId = hashedAccountId, ExternalUserId = externalUserId }); await Task.WhenAll(apiGetAccountTask, accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask).ConfigureAwait(false); var accountResponse = accountResponseTask.Result; var userRoleResponse = userRoleResponseTask.Result; var userResponse = userResponseTask.Result; var accountStatsResponse = accountStatsResponseTask.Result; var agreementsResponse = agreementsResponseTask.Result; var accountDetailViewModel = apiGetAccountTask.Result; var apprenticeshipEmployerType = (ApprenticeshipEmployerType)Enum.Parse(typeof(ApprenticeshipEmployerType), accountDetailViewModel.ApprenticeshipEmployerType, true); var tasksResponse = await _mediator.SendAsync(new GetAccountTasksQuery { AccountId = accountResponse.Account.Id, ExternalUserId = externalUserId, ApprenticeshipEmployerType = apprenticeshipEmployerType }); var pendingAgreements = agreementsResponse.EmployerAgreements.Where(a => a.HasPendingAgreement && !a.HasSignedAgreement).Select(a => new PendingAgreementsViewModel { HashedAgreementId = a.Pending.HashedAgreementId }).ToList(); var tasks = tasksResponse?.Tasks.Where(t => t.ItemsDueCount > 0 && t.Type != "AgreementToSign").ToList() ?? new List <AccountTask>(); var showWizard = userResponse.User.ShowWizard && userRoleResponse.UserRole == Role.Owner; var viewModel = new AccountDashboardViewModel { Account = accountResponse.Account, UserRole = userRoleResponse.UserRole, HashedUserId = externalUserId, UserFirstName = userResponse.User.FirstName, OrganisationCount = accountStatsResponse?.Stats?.OrganisationCount ?? 0, PayeSchemeCount = accountStatsResponse?.Stats?.PayeSchemeCount ?? 0, TeamMemberCount = accountStatsResponse?.Stats?.TeamMemberCount ?? 0, TeamMembersInvited = accountStatsResponse?.Stats?.TeamMembersInvited ?? 0, ShowWizard = showWizard, ShowAcademicYearBanner = _currentDateTime.Now < new DateTime(2017, 10, 20), Tasks = tasks, HashedAccountId = hashedAccountId, RequiresAgreementSigning = pendingAgreements.Count(), SignedAgreementCount = agreementsResponse.EmployerAgreements.Count(x => x.HasSignedAgreement), PendingAgreements = pendingAgreements, ApprenticeshipEmployerType = apprenticeshipEmployerType, AgreementInfo = _mapper.Map <AccountDetailViewModel, AgreementInfoViewModel>(accountDetailViewModel) }; //note: ApprenticeshipEmployerType is already returned by GetEmployerAccountHashedQuery, but we need to transition to calling the api instead. // 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 <AccountDashboardViewModel> { Status = HttpStatusCode.OK, Data = viewModel }); } catch (UnauthorizedAccessException ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.Unauthorized, Exception = ex }); } catch (System.Net.Http.HttpRequestException ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.InternalServerError, Exception = new ResourceNotFoundException($"An error occured whilst trying to retrieve account: {hashedAccountId}", ex) }); } catch (Exception ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.InternalServerError, Exception = ex }); } }
public void Arrange() { mockAuthenticationService = new Mock <IAuthenticationService>(); mockMultiVariantTestingService = new Mock <IMultiVariantTestingService>(); mockCookieStorageService = new Mock <ICookieStorageService <FlashMessageViewModel> >(); mockEmployerTeamOrchestrator = new Mock <EmployerTeamOrchestrator>(); mockControllerContext = new Mock <ControllerContext>(); mockHttpContext = new Mock <HttpContextBase>(); mockPrincipal = new Mock <IPrincipal>(); mockClaimsIdentity = new Mock <ClaimsIdentity>(); _userId = "TestUser"; _claims = new List <Claim> { new Claim(ControllerConstants.UserRefClaimKeyName, _userId) }; mockPrincipal.Setup(m => m.Identity).Returns(mockClaimsIdentity.Object); mockClaimsIdentity.Setup(m => m.IsAuthenticated).Returns(_isAuthenticated); mockClaimsIdentity.Setup(m => m.Claims).Returns(_claims); mockHttpContext.Setup(m => m.User).Returns(mockPrincipal.Object); mockControllerContext.Setup(m => m.HttpContext).Returns(mockHttpContext.Object); _hashedAccountId = Guid.NewGuid().ToString(); _account = new Account { PublicHashedId = _hashedAccountId }; _accountViewModel = new AccountDashboardViewModel { Account = _account }; _accountSummaryViewModel = new AccountSummaryViewModel { Account = _account }; _orchestratorResponse = new OrchestratorResponse <AccountDashboardViewModel>() { Status = System.Net.HttpStatusCode.OK, Data = _accountViewModel }; _orchestratorAccountSummaryResponse = new OrchestratorResponse <AccountSummaryViewModel>() { Status = System.Net.HttpStatusCode.OK, Data = _accountSummaryViewModel }; mockEmployerTeamOrchestrator .Setup(m => m.GetAccount(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(_orchestratorResponse); _controller = new EmployerTeamController( mockAuthenticationService.Object, mockMultiVariantTestingService.Object, mockCookieStorageService.Object, mockEmployerTeamOrchestrator.Object) { ControllerContext = mockControllerContext.Object }; }
public async Task <OrchestratorResponse <AccountDashboardViewModel> > GetAccount(string accountId, string externalUserId) { try { var accountResponseTask = _mediator.SendAsync(new GetEmployerAccountHashedQuery { HashedAccountId = accountId, UserId = externalUserId }); var userRoleResponseTask = GetUserAccountRole(accountId, externalUserId); var userResponseTask = _mediator.SendAsync(new GetTeamMemberQuery { HashedAccountId = accountId, TeamMemberId = externalUserId }); var accountStatsResponseTask = _mediator.SendAsync(new GetAccountStatsQuery { HashedAccountId = accountId, ExternalUserId = externalUserId }); var agreementsResponseTask = _mediator.SendAsync(new GetAccountEmployerAgreementsRequest { HashedAccountId = accountId, ExternalUserId = externalUserId }); await Task.WhenAll(accountStatsResponseTask, userRoleResponseTask, userResponseTask, accountStatsResponseTask, agreementsResponseTask).ConfigureAwait(false); var accountResponse = accountResponseTask.Result; var userRoleResponse = userRoleResponseTask.Result; var userResponse = userResponseTask.Result; var accountStatsResponse = accountStatsResponseTask.Result; var agreementsResponse = agreementsResponseTask.Result; var tasksResponse = await _mediator.SendAsync(new GetAccountTasksQuery { AccountId = accountResponse.Account.Id, ExternalUserId = externalUserId }); var requiresAgreementSigning = agreementsResponse.EmployerAgreements.Count(a => a.HasPendingAgreement); var tasks = tasksResponse?.Tasks.Where(t => t.ItemsDueCount > 0 && t.Type != "AgreementToSign").ToList() ?? new List <AccountTask>(); var showWizard = userResponse.User.ShowWizard && userRoleResponse.UserRole == Role.Owner; var viewModel = new AccountDashboardViewModel { Account = accountResponse.Account, UserRole = userRoleResponse.UserRole, HashedUserId = externalUserId, UserFirstName = userResponse.User.FirstName, OrgainsationCount = accountStatsResponse?.Stats?.OrganisationCount ?? 0, PayeSchemeCount = accountStatsResponse?.Stats?.PayeSchemeCount ?? 0, TeamMemberCount = accountStatsResponse?.Stats?.TeamMemberCount ?? 0, TeamMembersInvited = accountStatsResponse?.Stats?.TeamMembersInvited ?? 0, ShowWizard = showWizard, ShowAcademicYearBanner = _currentDateTime.Now < new DateTime(2017, 10, 20), Tasks = tasks, HashedAccountId = accountId, RequiresAgreementSigning = requiresAgreementSigning, AgreementsToSign = requiresAgreementSigning > 0, SignedAgreementCount = agreementsResponse.EmployerAgreements.Count(x => x.HasSignedAgreement) }; return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.OK, Data = viewModel }); } catch (UnauthorizedAccessException ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.Unauthorized, Exception = ex }); } catch (Exception ex) { return(new OrchestratorResponse <AccountDashboardViewModel> { Status = HttpStatusCode.InternalServerError, Exception = ex }); } }
public void Arrange() { _mockAccountContext = new Mock <ICookieStorageService <AccountContext> >(); _employerTeamOrchestrator = new Mock <EmployerTeamOrchestrator>(); AccountDashboardViewModel = new AccountDashboardViewModel { HashedAccountId = HashedAccountId }; _employerTeamOrchestrator .Setup(m => m.GetAccount(HashedAccountId, UserId)) .ReturnsAsync(new OrchestratorResponse <AccountDashboardViewModel> { Data = AccountDashboardViewModel, Status = HttpStatusCode.OK }); _mediator = new Mock <IMediator>(); _mediator.Setup(x => x.SendAsync(It.IsAny <GetVacanciesRequest>())) .ReturnsAsync(new GetVacanciesResponse { Vacancies = new List <Vacancy>() }); _mediator.Setup(m => m.SendAsync(It.Is <GetReservationsRequest>(q => q.HashedAccountId == HashedAccountId))) .ReturnsAsync(new GetReservationsResponse { Reservations = new List <Reservation> { new Reservation { AccountId = 123 } } }); _mediator.Setup(m => m.SendAsync(It.Is <GetApprenticeshipsRequest>(q => q.HashedAccountId == HashedAccountId))) .ReturnsAsync(new GetApprenticeshipsResponse { Apprenticeships = new List <Apprenticeship> { new Apprenticeship { FirstName = "FirstName" } } }); var Cohort = new Cohort() { Id = 1, CohortStatus = EmployerAccounts.Models.CommitmentsV2.CohortStatus.WithTrainingProvider, NumberOfDraftApprentices = 1, Apprenticeships = new List <Apprenticeship> { 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 <GetSingleCohortRequest>())) .ReturnsAsync(new GetSingleCohortResponse { Cohort = Cohort }); _mockCurrentDateTime = new Mock <ICurrentDateTime>(); _mockAccountApiClient = new Mock <IAccountApiClient>(); _mockAccountApiClient.Setup(c => c.GetAccount(HashedAccountId)).ReturnsAsync(new AccountDetailViewModel { ApprenticeshipEmployerType = "Levy" }); _mockMapper = new Mock <IMapper>(); _mockLogger = new Mock <ILog>(); _sut = new EmployerTeamOrchestratorWithCallToAction( _employerTeamOrchestrator.Object, _mediator.Object, _mockCurrentDateTime.Object, _mockAccountApiClient.Object, _mockMapper.Object, _mockAccountContext.Object, _mockLogger.Object); }
public ActionResult SingleApprenticeshipWithTrainingProvider(AccountDashboardViewModel model) { return(PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single())); }
public ActionResult VacancyClosed(AccountDashboardViewModel model) { return(PartialView(model.CallToActionViewModel.VacanciesViewModel.Vacancies.First(m => m.Status == EmployerAccounts.Models.Recruit.VacancyStatus.Closed))); }
public ActionResult SingleApprenticeshipReadyForReview(AccountDashboardViewModel model) { return(PartialView(model.CallToActionViewModel.Cohorts.Single().Apprenticeships.Single())); }
public ActionResult CheckFunding(AccountDashboardViewModel model) { return(PartialView(model)); }
public ActionResult Empty(AccountDashboardViewModel model) { return(PartialView(model)); }
public ActionResult SignAgreement(AccountDashboardViewModel model) { return(PartialView(model)); }
public ActionResult SingleApprenticeshipApproved(AccountDashboardViewModel model) { return(PartialView(model.CallToActionViewModel.Apprenticeships.First())); }