Example #1
0
        public void IndexTest(bool isAdmin, int batchSizeForImport)
        {
            // Assign
            var skillsFrameworkDataImportController = GetSkillsFrameworkDataImportController(isAdmin, batchSizeForImport);

            // Act
            var indexMethodCall = skillsFrameworkDataImportController.WithCallTo(c => c.Index());

            // Assert
            indexMethodCall
            .ShouldRenderDefaultView()
            .WithModel <SkillsFrameworkImportViewModel>(vm =>
            {
                vm.FirstParagraph.Should().BeEquivalentTo(skillsFrameworkDataImportController.FirstParagraph);
                vm.IsAdmin.Should().Be(fakeWebAppContext.IsUserAdministrator);
                vm.NotAllowedMessage.Should().BeEquivalentTo(skillsFrameworkDataImportController.NotAllowedMessage);
                vm.PageTitle.Should().BeEquivalentTo(skillsFrameworkDataImportController.PageTitle);
            })
            .AndNoModelErrors();

            A.CallTo(() => fakeWebAppContext.IsUserAdministrator).MustHaveHappened();
            A.CallTo(() => fakeImportSkillsFrameworkDataService.UpdateSocCodesOccupationalCode()).MustNotHaveHappened();
            A.CallTo(() => fakeImportSkillsFrameworkDataService.ImportFrameworkSkills()).MustNotHaveHappened();
            A.CallTo(() => fakeReportAuditRepository.GetAllAuditRecords()).MustNotHaveHappened();
        }
Example #2
0
        public ActionResult Index(string importMode)
        {
            var importResult = new SkillsFrameworkResultsViewModel
            {
                PageTitle               = PageTitle,
                FirstParagraph          = FirstParagraph,
                NotAllowedMessage       = NotAllowedMessage,
                IsAdmin                 = webAppContext.IsUserAdministrator,
                SocMappingStatus        = importSkillsFrameworkDataService.GetSocMappingStatus(),
                NextBatchOfSOCsToImport = importSkillsFrameworkDataService.GetNextBatchOfSOCsToImport(BatchSizeForImport)
            };

            var otherMessage = string.Empty;

            if (webAppContext.IsUserAdministrator)
            {
                try
                {
                    switch (importMode?.ToUpperInvariant().Trim())
                    {
                    case "IMPORTSKILLS":
                        importSkillsFrameworkDataService.ImportFrameworkSkills();
                        importResult.ActionCompleted = "Imported Onet Skills";
                        break;

                    case "UPDATESOCOCCUPATIONALCODES":
                        importSkillsFrameworkDataService.UpdateSocCodesOccupationalCode();
                        importResult.ActionCompleted = "Updated SOC with Onet Occupational Codes";
                        break;

                    case "RESETSOCIMPORTALLSTATUS":
                        importSkillsFrameworkDataService.ResetAllSocStatus();
                        importResult.ActionCompleted = "Import status for all SOCs has been reset  ";
                        break;

                    case "RESETSOCIMPORTSTARTEDSTATUS":
                        importSkillsFrameworkDataService.ResetStartedSocStatus();
                        importResult.ActionCompleted = "Import status for Started SOCs has been reset  ";
                        break;

                    case "EXPORTNEWONETMAPPINGS":
                        importSkillsFrameworkDataService.ExportNewONetMappings();
                        importResult.ActionCompleted = "New SOC to ONet mappings exported";
                        break;

                    default:
                        importResult.ActionCompleted = "Action unknown - no process was run.";
                        break;
                    }
                }
                catch (Exception ex)
                {
                    otherMessage = $"{ex.Message} <br /> {ex.InnerException} <br /> {ex.StackTrace}";
                }
            }
            else
            {
                otherMessage = NotAllowedMessage;
            }

            importResult.AuditRecords = reportAuditRepository.GetAllAuditRecords();
            importResult.OtherMessage = otherMessage;

            return(View("ImportResults", importResult));
        }