protected override void UpdateHistory(ApprenticeshipModel current, UpdatedApprenticeshipPausedModel updated) { var newPauseModel = new ApprenticeshipPauseModel { ApprenticeshipId = updated.ApprenticeshipId, PauseDate = updated.PauseDate }; current.ApprenticeshipPauses.Add(newPauseModel); }
protected override async Task UpdateHistoryTables(UpdatedApprenticeshipPausedModel updated) { var newPauseModel = new ApprenticeshipPauseModel { ApprenticeshipId = updated.ApprenticeshipId, PauseDate = updated.PauseDate }; await repository.AddApprenticeshipPause(newPauseModel); }
public async Task Updates_Resumed_Apprenticeship() { var updatedApprenticeship = new UpdatedApprenticeshipResumedModel { ApprenticeshipId = 629959, ResumedDate = DateTime.Today }; var apprenticeshipModel = new ApprenticeshipModel { Id = updatedApprenticeship.ApprenticeshipId, StopDate = DateTime.Today.AddMonths(6), Status = ApprenticeshipStatus.Paused, Uln = 1, AgreedOnDate = DateTime.Today.AddDays(-2), EstimatedStartDate = DateTime.Today.AddMonths(-5), EstimatedEndDate = DateTime.Today.AddYears(1), ProgrammeType = 25, StandardCode = 17, ApprenticeshipPriceEpisodes = new List <ApprenticeshipPriceEpisodeModel> { new ApprenticeshipPriceEpisodeModel { Id = 1, ApprenticeshipId = updatedApprenticeship.ApprenticeshipId, StartDate = new DateTime(2017, 08, 06), Cost = 15000.00m }, new ApprenticeshipPriceEpisodeModel { Id = 161, ApprenticeshipId = updatedApprenticeship.ApprenticeshipId, StartDate = new DateTime(2017, 08, 10), Cost = 1000.00m } }, Ukprn = 100, TransferSendingEmployerAccountId = 101, AccountId = 1, AgreementId = "1", IsLevyPayer = true, LegalEntityName = "Test Employer", FrameworkCode = 1, PathwayCode = 1, }; var pauseModel = new ApprenticeshipPauseModel { ApprenticeshipId = updatedApprenticeship.ApprenticeshipId, PauseDate = DateTime.Today.AddMonths(-2) }; apprenticeshipModel.ApprenticeshipPauses.Add(pauseModel); mocker.Mock <IApprenticeshipRepository>() .Setup(x => x.Get(It.Is <long>(id => id == apprenticeshipModel.Id))) .ReturnsAsync(apprenticeshipModel); mocker.Mock <IApprenticeshipRepository>() .Setup(x => x.GetCurrentApprenticeshipPausedModel(updatedApprenticeship.ApprenticeshipId)) .ReturnsAsync(pauseModel); var service = mocker.Create <ApprenticeshipResumedService>(); var result = await service.UpdateApprenticeship(updatedApprenticeship); mocker.Mock <IApprenticeshipRepository>() .Verify(x => x.UpdateApprenticeship(It.Is <ApprenticeshipModel>(model => model.Id == updatedApprenticeship.ApprenticeshipId && model.Status == ApprenticeshipStatus.Active && model.ApprenticeshipPriceEpisodes.Count == 2 && model.ApprenticeshipPriceEpisodes[0].Cost == apprenticeshipModel.ApprenticeshipPriceEpisodes[0].Cost && model.ApprenticeshipPriceEpisodes[0].StartDate == apprenticeshipModel.ApprenticeshipPriceEpisodes[0].StartDate && model.ApprenticeshipPriceEpisodes[1].StartDate == apprenticeshipModel.ApprenticeshipPriceEpisodes[1].StartDate && model.ApprenticeshipPriceEpisodes[1].Cost == apprenticeshipModel.ApprenticeshipPriceEpisodes[1].Cost && model.Uln == apprenticeshipModel.Uln && model.AgreedOnDate == apprenticeshipModel.AgreedOnDate && model.EstimatedStartDate == apprenticeshipModel.EstimatedStartDate && model.EstimatedEndDate == apprenticeshipModel.EstimatedEndDate && model.ProgrammeType == apprenticeshipModel.ProgrammeType && model.StandardCode == apprenticeshipModel.StandardCode && model.Ukprn == apprenticeshipModel.Ukprn && model.TransferSendingEmployerAccountId == apprenticeshipModel.TransferSendingEmployerAccountId && model.AccountId == apprenticeshipModel.AccountId && model.AgreementId == apprenticeshipModel.AgreementId && model.IsLevyPayer == apprenticeshipModel.IsLevyPayer && model.LegalEntityName == apprenticeshipModel.LegalEntityName && model.FrameworkCode == apprenticeshipModel.FrameworkCode && model.PathwayCode == apprenticeshipModel.FrameworkCode )), Times.Once); mocker.Mock <IApprenticeshipRepository>() .Verify(x => x.Get(It.Is <long>(id => id == apprenticeshipModel.Id)), Times.Exactly(2)); result.Status.Should().Be(ApprenticeshipStatus.Active); pauseModel = result.ApprenticeshipPauses .OrderByDescending(x => x.PauseDate) .FirstOrDefault(); pauseModel.Should().NotBeNull(); pauseModel.ResumeDate.Should().HaveValue(); }
public async Task UpdateCurrentlyPausedApprenticeship(ApprenticeshipPauseModel apprenticeshipPauseModel) { dataContext.ApprenticeshipPause.Update(apprenticeshipPauseModel); await dataContext.SaveChangesAsync().ConfigureAwait(false); }
public async Task AddApprenticeshipPause(ApprenticeshipPauseModel pauseModel) { dataContext.ApprenticeshipPause.Add(pauseModel); await dataContext.SaveChangesAsync(); }