コード例 #1
0
        /// <summary>
        /// Processes the terms on the external policy, adding each to the GeniusX policy in turn.
        /// </summary>
        /// <param name="xiapHeader">The xiap header.</param>
        /// <param name="externalTerms">The external terms.</param>
        private void ProcessTerms(Header xiapHeader, IUWTerms externalTerms)
        {
            // Get the current terms on the GeniusX policy and the Product Version.
            Terms terms = xiapHeader.Terms.FirstOrDefault();
            long productVersionID = xiapHeader.GetProduct().ProductVersionID;
            if (terms == null)
            {
                // We have no terms on the policy at all, so first get the default terms from the product.
                using (MetadataEntities metadata = MetadataEntitiesFactory.GetMetadataEntities())
                {
                    ProductTerms productTerms = metadata.ProductTerms.Where(a => a.ProductVersion.ProductVersionID == productVersionID && a.IsDefault == true).FirstOrDefault();
                    if (productTerms != null)
                    {
                        // Map default terms to the GeniusX policy
                        terms = xiapHeader.AddNewTerms(productTerms.ProductTermsID);
                    }
                }
            }

            // Note that this isn't an 'else if'. We should always have terms at this point, and now we map the external data onto them.
            if (terms != null)
            {
                // Update terms on GeniusX policy with the required data from the External policy.
                terms.ExternalReference = externalTerms.ExternalReference;
                TermsVersion termsVersion = (TermsVersion)terms.GetLatestVersion();
                if (termsVersion != null)
                {
                    termsVersion.TermsTitle = externalTerms.TermsTitle;
                    termsVersion.MainOriginalCurrencyCode = externalTerms.MainOriginalCurrencyCode;
                }
            }
        }