public void MigrateOnewayAgreement(
            Services.TpmContext cloudContext,
            Server.OnewayAgreement serverOnewayAgreement,
            Server.QualifierIdentity serverSenderBusinessIdentity,
            Server.QualifierIdentity serverReceiverBusinessIdentity,
            Services.Agreement cloudAgreement,
            string onewayAgreementType,
            out MigrationStatus migrationStatus)
        {
            Services.OnewayAgreement cloudOnewayAgreement = new Services.OnewayAgreement();
            cloudContext.AddToOnewayAgreements(cloudOnewayAgreement);
            cloudContext.RelateEntities(
                cloudOnewayAgreement,
                cloudAgreement,
                onewayAgreementType == "OnewayAgreementAToB" ? "AgreementAsAToB" : "AgreementAsBToA",
                onewayAgreementType,
                Services.RelationshipCardinality.OneToOne);

            this.LinkBusinessProfilesToOnewayAgreement(
                cloudContext,
                cloudOnewayAgreement,
                cloudAgreement.BusinessProfileA,
                cloudAgreement.BusinessProfileB,
                serverSenderBusinessIdentity,
                serverReceiverBusinessIdentity,
                onewayAgreementType);

            // Migrate send and receive protocol settings
            Server.ProtocolSettings serverProtocolSettings;
            switch (cloudAgreement.ProtocolName)
            {
            case AppConstants.X12ProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.X12ProtocolSettings>();
                break;

            case AppConstants.AS2ProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.AS2ProtocolSettings>();
                break;

            case AppConstants.EdifactProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.EDIFACTProtocolSettings>();
                break;

            default:
                throw new NotSupportedException("Migration of  X12, AS2, EDIFACT agreements only is supported");
            }

            this.protocolSettingsMigrator.MigrateProtocolSettings(cloudContext, cloudOnewayAgreement, serverProtocolSettings, onewayAgreementType == "OnewayAgreementAToB" ? cloudAgreement.BusinessProfileA : cloudAgreement.BusinessProfileB, cloudAgreement.Name, out migrationStatus);
        }
        public void MigrateOnewayAgreements(Services.TpmContext cloudContext, Server.Agreement serverAgreement, string serverAgreementSenderPartnerName, string serverAgreementReceiverPartnername, Services.Agreement cloudAgreement, out MigrationStatus migrationStatus)
        {
            migrationStatus = MigrationStatus.Succeeded;
            Server.OnewayAgreement serverSendOnewayAgreement    = serverAgreement.GetOnewayAgreement(serverAgreementSenderPartnerName, serverAgreementReceiverPartnername);
            Server.OnewayAgreement serverReceiveOnewayAgreement = serverAgreement.GetOnewayAgreement(serverAgreementReceiverPartnername, serverAgreementSenderPartnerName);

            var             serverSenderBusinessIdentity       = serverSendOnewayAgreement.SenderIdentity as Server.QualifierIdentity;
            var             serverReceiverBusinessIdentity     = serverSendOnewayAgreement.ReceiverIdentity as Server.QualifierIdentity;
            MigrationStatus onewayAgreementAToBMigrationStatus = MigrationStatus.Succeeded;

            this.MigrateOnewayAgreement(cloudContext, serverSendOnewayAgreement, serverSenderBusinessIdentity, serverReceiverBusinessIdentity, cloudAgreement, "OnewayAgreementAToB", out onewayAgreementAToBMigrationStatus);
            MigrationStatus onewayAgreementBToAMigrationStatus = MigrationStatus.Succeeded;

            this.MigrateOnewayAgreement(cloudContext, serverReceiveOnewayAgreement, serverReceiverBusinessIdentity, serverSenderBusinessIdentity, cloudAgreement, "OnewayAgreementBToA", out onewayAgreementBToAMigrationStatus);

            if (onewayAgreementAToBMigrationStatus == MigrationStatus.Partial || onewayAgreementBToAMigrationStatus == MigrationStatus.Partial)
            {
                migrationStatus = MigrationStatus.Partial;
            }
        }