public void ImportForSingleSocNoSocTest()
        {
            var dummySoc = GetSOCs(1).FirstOrDefault();

            //Arrange
            A.CallTo(() => fakeSkillsFrameworkService.SetSocStatusCompleted(A <SocCode> ._)).DoesNothing();
            A.CallTo(() => fakeJobProfileSocCodeRepository.GetBySocCode(A <string> ._)).Returns(null);
            var skillsImportService = new SkillsFrameworkDataImportService(fakeSkillsFrameworkService, fakeFrameworkSkillRepository, fakeJobProfileSocCodeRepository, fakeJobProfileRepository, fakeSocSkillMatrixRepository, fakeReportAuditRepository);

            //Act
            skillsImportService.ImportForSingleSoc(dummySoc.SOCCode);

            //asserts
            A.CallTo(() => fakeReportAuditRepository.CreateAudit("ErrorDetails", A <string> ._)).MustHaveHappened();
            A.CallTo(() => fakeSkillsFrameworkService.SetSocStatusCompleted(A <SocCode> ._)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeReportAuditRepository.CreateAudit("ActionDetails", A <string> ._)).MustHaveHappened();
        }
        public void ImportForSingleSoc(string jobProfileSoc)
        {
            var lockedJobProfiles = new List <JobProfileOverloadForWhatItTakes>();

            reportAuditRepository.CreateAudit(ActionDetailsKey, $"Updating Job profiles for SOC - {jobProfileSoc}");
            var soc = jobProfileSocCodeRepository.GetBySocCode(jobProfileSoc);

            if (soc == null)
            {
                reportAuditRepository.CreateAudit(ErrorDetailsKey, $"SOC - {jobProfileSoc} NOT found in Sitefinity!");
                soc = new SocCode {
                    SOCCode = jobProfileSoc
                };
            }
            else
            {
                skillsFrameworkService.SetSocStatusSelectedForUpdate(soc);
                var jobProfilesForSoc = jobProfileSocCodeRepository.GetLiveJobProfilesBySocCode(soc.SOCCode).ToList();
                reportAuditRepository.CreateAudit(ActionDetailsKey,
                                                  $"Found {jobProfilesForSoc.Count} job profiles for SOC {soc.SOCCode}");

                lockedJobProfiles = jobProfilesForSoc.Where(x => x.Locked).ToList();
                foreach (var lockedJobProfile in lockedJobProfiles)
                {
                    reportAuditRepository.CreateAudit(SummaryDetailsKey, $"{lockedJobProfile.UrlName} could not be updated as it is locked or already in a Draft status with Soc code {jobProfileSoc}");
                }

                var safeJobProfiles = jobProfilesForSoc.Where(x => !x.Locked).ToList();
                //We have safe job linked to the SOC
                if (safeJobProfiles.Any())
                {
                    var socSkillMatrixData = CreateSocSkillsMatrixRecords(soc);
                    var digitalSkillLevel  = skillsFrameworkService.GetDigitalSkillLevel(soc.ONetOccupationalCode);
                    reportAuditRepository.CreateAudit(ActionDetailsKey,
                                                      $"Got {digitalSkillLevel} for Occupational Code : {soc.ONetOccupationalCode} SOC {soc.SOCCode} from SkillFramework Service");
                    var digitSkillValue = Convert.ToInt32(digitalSkillLevel).ToString();

                    //DO all profiles that exist for this code
                    foreach (var profile in safeJobProfiles)
                    {
                        if (socSkillMatrixData.Any())
                        {
                            profile.DigitalSkillsLevel = digitSkillValue;
                            jobProfileRepository.UpdateSocSkillMatrices(profile, socSkillMatrixData);
                            reportAuditRepository.CreateAudit(ActionDetailsKey,
                                                              $"Linked Job Profile {profile.UrlName} with the following socskilmatrices {string.Join(", ", socSkillMatrixData.ToList().Select(sk => sk.Title))}");
                        }
                    }

                    reportAuditRepository.CreateAudit(ActionDetailsKey, $"Updated job profiles SOC {jobProfileSoc}");
                }
                else
                {
                    reportAuditRepository.CreateAudit(ErrorDetailsKey,
                                                      $"Found {safeJobProfiles.Count} unlocked job profiles for SOC {soc.SOCCode}");
                }
            }
            if (!lockedJobProfiles.Any())
            {
                skillsFrameworkService.SetSocStatusCompleted(soc);
                reportAuditRepository.CreateAudit(ActionDetailsKey, $"Set status to Completed for SOC {soc.SOCCode}");
            }
            reportAuditRepository.CreateAudit(ActionDetailsKey, "-----------------------------------------------------------------------------------------------------------------------------");
            reportAuditRepository.CreateAudit(ActionDetailsKey, " ");
        }