/// <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 DraftApprenticeship CreateCopyForChangeOfParty(ChangeOfPartyRequest changeOfPartyRequest, Guid?reservationId)
        {
            var result = new DraftApprenticeship
            {
                FirstName         = this.FirstName,
                LastName          = this.LastName,
                DateOfBirth       = this.DateOfBirth,
                Cost              = changeOfPartyRequest.Price,
                StartDate         = changeOfPartyRequest.StartDate,
                EndDate           = changeOfPartyRequest.EndDate,
                Uln               = this.Uln,
                CourseCode        = this.CourseCode,
                CourseName        = this.CourseName,
                ProgrammeType     = this.ProgrammeType,
                EmployerRef       = changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeEmployer ? string.Empty : this.EmployerRef,
                ProviderRef       = changeOfPartyRequest.ChangeOfPartyType == ChangeOfPartyRequestType.ChangeProvider ? string.Empty : this.ProviderRef,
                ReservationId     = reservationId,
                ContinuationOfId  = Id,
                OriginalStartDate = OriginalStartDate ?? StartDate
            };

            return(result);
        }