private void CheckIsCompleteForParty(Party party) { if (!DraftApprenticeships.Any()) { throw new DomainException(nameof(Apprenticeships), $"Cohort must have at least one draft apprenticeship"); } if (party == Party.Employer || party == Party.Provider) { if (DraftApprenticeships.Any(x => !x.IsCompleteForParty(party))) { throw new DomainException(nameof(DraftApprenticeships), $"Cohort must be complete for {party}"); } } }
public void DeleteDraftApprenticeship(long draftApprenticeshipId, Party modifyingParty, UserInfo userInfo) { CheckIsWithParty(modifyingParty); var draftApprenticeship = DraftApprenticeships.Single(x => x.Id == draftApprenticeshipId); StartTrackingSession(UserAction.DeleteDraftApprenticeship, modifyingParty, EmployerAccountId, ProviderId, userInfo); ChangeTrackingSession.TrackUpdate(this); RemoveDraftApprenticeship(draftApprenticeship); LastUpdatedOn = DateTime.UtcNow; Approvals = Party.None; ResetTransferSenderRejection(); if (!DraftApprenticeships.Any()) { MarkAsDeletedAndEmitCohortDeletedEvent(modifyingParty, userInfo); } ChangeTrackingSession.CompleteTrackingSession(); }