/// <summary> /// Creates a cohort with a draft apprenticeship /// </summary> internal Cohort(long providerId, long accountId, long accountLegalEntityId, long?transferSenderId, DraftApprenticeshipDetails draftApprenticeshipDetails, Party originatingParty, UserInfo userInfo) : this(providerId, accountId, accountLegalEntityId, transferSenderId, originatingParty, userInfo) { CheckDraftApprenticeshipDetails(draftApprenticeshipDetails); ValidateDraftApprenticeshipDetails(draftApprenticeshipDetails, false); WithParty = originatingParty; EditStatus = originatingParty.ToEditStatus(); IsDraft = true; var draftApprenticeship = new DraftApprenticeship(draftApprenticeshipDetails, originatingParty); Apprenticeships.Add(draftApprenticeship); Publish(() => new DraftApprenticeshipCreatedEvent(draftApprenticeship.Id, Id, draftApprenticeship.Uln, draftApprenticeship.ReservationId, draftApprenticeship.CreatedOn.Value)); StartTrackingSession(UserAction.CreateCohort, originatingParty, accountId, providerId, userInfo); ChangeTrackingSession.TrackInsert(this); ChangeTrackingSession.TrackInsert(draftApprenticeship); ChangeTrackingSession.CompleteTrackingSession(); }
/// <summary> /// Creates a Cohort from a Change of Party Request /// </summary> internal Cohort(long providerId, long accountId, long accountLegalEntityId, Apprenticeship apprenticeship, Guid?reservationId, ChangeOfPartyRequest changeOfPartyRequest, UserInfo userInfo) : this(providerId, accountId, accountLegalEntityId, null, changeOfPartyRequest.OriginatingParty, userInfo) { ChangeOfPartyRequestId = changeOfPartyRequest.Id; Approvals = changeOfPartyRequest.IsPreApproved(); WithParty = changeOfPartyRequest.OriginatingParty.GetOtherParty(); IsDraft = false; if (changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeProvider) { TransferSenderId = apprenticeship.Cohort.TransferSenderId; } var draftApprenticeship = apprenticeship.CreateCopyForChangeOfParty(changeOfPartyRequest, reservationId); Apprenticeships.Add(draftApprenticeship); //Retained for backwards-compatibility: EditStatus = WithParty.ToEditStatus(); LastAction = LastAction.Amend; CommitmentStatus = CommitmentStatus.Active; Publish(() => new CohortWithChangeOfPartyCreatedEvent(Id, changeOfPartyRequest.Id, changeOfPartyRequest.OriginatingParty, DateTime.UtcNow, userInfo)); if (changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeEmployer) { Publish(() => new CohortAssignedToEmployerEvent(Id, DateTime.UtcNow, Party.Provider)); } else { Publish(() => new CohortAssignedToProviderEvent(Id, DateTime.UtcNow)); } StartTrackingSession(UserAction.CreateCohortWithChangeOfParty, changeOfPartyRequest.OriginatingParty, accountId, providerId, userInfo); ChangeTrackingSession.TrackInsert(this); ChangeTrackingSession.TrackInsert(draftApprenticeship); ChangeTrackingSession.CompleteTrackingSession(); }
public virtual bool IsApprovedByAllParties => WithParty == Party.None; //todo: use new Approvals flag public DraftApprenticeship AddDraftApprenticeship(DraftApprenticeshipDetails draftApprenticeshipDetails, Party creator, UserInfo userInfo) { CheckIsWithParty(creator); ValidateDraftApprenticeshipDetails(draftApprenticeshipDetails, false); StartTrackingSession(UserAction.AddDraftApprenticeship, creator, EmployerAccountId, ProviderId, userInfo); ChangeTrackingSession.TrackUpdate(this); var draftApprenticeship = new DraftApprenticeship(draftApprenticeshipDetails, creator); Apprenticeships.Add(draftApprenticeship); Approvals = Party.None; UpdatedBy(creator, userInfo); LastUpdatedOn = DateTime.UtcNow; ChangeTrackingSession.TrackInsert(draftApprenticeship); ChangeTrackingSession.CompleteTrackingSession(); Publish(() => new DraftApprenticeshipCreatedEvent(draftApprenticeship.Id, Id, draftApprenticeship.Uln, draftApprenticeship.ReservationId, draftApprenticeship.CreatedOn.Value)); return(draftApprenticeship); }
public void AddApprenticeship(Apprenticeship apprenticeship) { Apprenticeships.Add(apprenticeship); }