private void UpdateApprenticeshipEntity(Apprenticeship existingApprenticeship, Apprenticeship updatedApprenticeship, UpdateApprenticeshipCommand message) { var doChangesRequireAgreement = _apprenticeshipUpdateRules.DetermineWhetherChangeRequiresAgreement(existingApprenticeship, updatedApprenticeship); existingApprenticeship.FirstName = updatedApprenticeship.FirstName; existingApprenticeship.LastName = updatedApprenticeship.LastName; existingApprenticeship.DateOfBirth = updatedApprenticeship.DateOfBirth; existingApprenticeship.NINumber = updatedApprenticeship.NINumber; existingApprenticeship.ULN = updatedApprenticeship.ULN; existingApprenticeship.CommitmentId = message.CommitmentId; existingApprenticeship.TrainingType = updatedApprenticeship.TrainingType; existingApprenticeship.TrainingCode = updatedApprenticeship.TrainingCode; existingApprenticeship.TrainingName = updatedApprenticeship.TrainingName; existingApprenticeship.Cost = updatedApprenticeship.Cost; existingApprenticeship.StartDate = updatedApprenticeship.StartDate; existingApprenticeship.EndDate = updatedApprenticeship.EndDate; existingApprenticeship.EmployerRef = updatedApprenticeship.EmployerRef; existingApprenticeship.ProviderRef = updatedApprenticeship.ProviderRef; existingApprenticeship.AgreementStatus = _apprenticeshipUpdateRules.DetermineNewAgreementStatus(existingApprenticeship.AgreementStatus, message.Caller.CallerType, doChangesRequireAgreement); existingApprenticeship.PaymentStatus = _apprenticeshipUpdateRules.DetermineNewPaymentStatus(existingApprenticeship.PaymentStatus, doChangesRequireAgreement); }
private bool UpdateApprenticeshipStatuses(UpdateCommitmentAgreementCommand command, LastAction latestAction, Apprenticeship apprenticeship) { bool hasChanged = false; var newApprenticeshipAgreementStatus = _apprenticeshipUpdateRules.DetermineNewAgreementStatus(apprenticeship.AgreementStatus, command.Caller.CallerType, latestAction); var newApprenticeshipPaymentStatus = _apprenticeshipUpdateRules.DetermineNewPaymentStatus(apprenticeship.PaymentStatus, newApprenticeshipAgreementStatus); if (apprenticeship.AgreementStatus != newApprenticeshipAgreementStatus) { apprenticeship.AgreementStatus = newApprenticeshipAgreementStatus; if (apprenticeship.AgreementStatus == AgreementStatus.BothAgreed && !apprenticeship.AgreedOn.HasValue) { apprenticeship.AgreedOn = _currentDateTime.Now; } hasChanged = true; } if (apprenticeship.PaymentStatus != newApprenticeshipPaymentStatus) { apprenticeship.PaymentStatus = newApprenticeshipPaymentStatus; hasChanged = true; } return(hasChanged); }