private Party ProcessProvider() { Party party = new Party(); party.PopulateFrom(_provider); party.party_type_cd_id.Value = GSC(SystemCodeType.PARTY_TYPE, "business"); party.Variable = new SqlVariable("buid_" + _provider.Code); _sqlEntities.Add(party); Business_unit bu = new Business_unit(); bu.PopulateFrom(_provider); bu.party_id.Value = party.Variable; _sqlEntities.Add(bu); if (_provider.Extra != null) { Business_unit_property bup = new Business_unit_property(); bup.PopulateFrom(_provider.Extra); _sqlEntities.Add(bup); } foreach (var id in _provider.AuthMethods) { Business_unit_product_id_auth_method bupiam = new Business_unit_product_id_auth_method(); bupiam.PopulateFrom(id); bupiam.business_unit_party_id.Value = party.Variable; _sqlEntities.Add(bupiam); } if (_provider.ExpediteFees.Count > 0) { Business_unit_product expediteFeeBUP = new Business_unit_product(); expediteFeeBUP.GenVariable(); expediteFeeBUP.end_date.Value = _provider.DisableDate; expediteFeeBUP.is_expedited.Value = false; expediteFeeBUP.party_id.Value = party.Variable; expediteFeeBUP.product_display_name.Value = Constants.EXPEDITE_FEE_DISPLAY_NAME; expediteFeeBUP.product_id.Value = GetBaseProduct(Constants.EXPEDITE_FEE_BASE_PRODUCT); expediteFeeBUP.product_internal_name.Value = Constants.EXPEDITE_FEE_INTERNAL_NAME; expediteFeeBUP.product_rule_cd_id.Value = null; expediteFeeBUP.settlement_action_cd_id.Value = null; expediteFeeBUP.start_date.Value = _provider.EnableDate; _sqlEntities.Add(expediteFeeBUP); AttachFeeCollection(_provider.ExpediteFees, expediteFeeBUP, "agency expedite"); } // // Set up the vc fee "product". // Business_unit_product vcFeeBUP = new Business_unit_product(); Service vcfeeService = new Service(null); vcFeeBUP.PopulateFrom(vcfeeService); vcFeeBUP.GenVariable(); vcFeeBUP.end_date.Value = _provider.DisableDate; vcFeeBUP.is_expedited.Value = false; vcFeeBUP.party_id.Value = party.Variable; vcFeeBUP.product_display_name.Value = Constants.VCFEE_DISPLAY_NAME; vcFeeBUP.product_id.Value = GetBaseProduct(Constants.VCFEE_BASE_PRODUCT); vcFeeBUP.product_internal_name.Value = Constants.VCFEE_INTERNAL_NAME; vcFeeBUP.product_rule_cd_id.Value = null; vcFeeBUP.settlement_action_cd_id.Value = null; vcFeeBUP.start_date.Value = _provider.EnableDate; _sqlEntities.Add(vcFeeBUP); AttachFeeCollection(_provider.AgencyFees, vcFeeBUP, "vitalchek processing"); foreach (var pc in _provider.PcpidConfigs) { Procheck_config config = new Procheck_config(); config.PopulateFrom(pc); config.business_unit_party_id.Value = party.Variable; _sqlEntities.Add(config); } foreach (var a in _provider.Addresses) { SqlRendering.Entities.Address address = new SqlRendering.Entities.Address(); address.PopulateFrom(a); address.party_id.Value = party.Variable; _sqlEntities.Add(address); } foreach (var x in _provider.Phones) { Phone_number phone = new Phone_number(); phone.PopulateFrom(x); phone.party_id.Value = party.Variable; _sqlEntities.Add(phone); } // // Say it with me: shipping is not a product. It is a service. // foreach (var x in _provider.ShippingServices) { Business_unit_product bup = new Business_unit_product(); bup.PopulateFrom(x); bup.party_id.Value = party.Variable; bup.product_id.Value = GetBaseProduct(x.BaseProduct); bup.Variable = new SqlVariable(x.BaseProduct + "_BUPID"); _services.Add(x, bup.Variable); _sqlEntities.Add(bup); AttachFeeCollection(x.Fees, bup, "delivery"); } foreach (var term in _provider.Terminals) { Business_unit_merchant_number bumn = new Business_unit_merchant_number(); bumn.PopulateFrom(term); bumn.business_unit_party_id.Value = party.Variable; bumn.provider_id.Value = _provider.Code; bumn.GenVariable(); _sqlEntities.Add(bumn); Terminal_id ti = new Terminal_id(); ti.PopulateFrom(term); ti.business_unit_merchant_number_id.Value = bumn.Variable; ti.GenVariable(); _sqlEntities.Add(ti); } foreach (var c in _provider.Contents) { Template t = new Template(); t.PopulateFrom(c); t.template_text.Value = _contentTexts[c.Text]; SqlVariable templateVariable = AddUniqueSqlEntity(t); Content_assignment ca = new Content_assignment(); ca.PopulateFrom(c); ca.attached_to_type_cd_id.Value = GSC(SystemCodeType.SYSTEM_OBJECT_TYPE, "business unit"); ca.template_id.Value = templateVariable; ca.attached_to_id.Value = party.Variable; _sqlEntities.Add(ca); } return party; }
private void ProcessProduct(Rad.Core.Domain.Product prod, Party party) { Business_unit_product bup = new Business_unit_product(); bup.PopulateFrom(prod); bup.Variable = new SqlVariable(_sqlVariableCleaner.Replace(prod.InternalName, new MatchEvaluator(a => "_")) + "_BUPID"); bup.party_id.Value = party.Variable; bup.product_id.Value = GetBaseProduct(prod.BaseProduct); _sqlEntities.Add(bup); AttachFeeCollection(prod.DocumentFees, bup, "document"); foreach (var pc in prod.PcpidConfigs) { Procheck_config config = new Procheck_config(); config.PopulateFrom(pc); config.business_unit_party_id.Value = party.Variable; config.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(config); } foreach (var id in prod.AuthMethods) { Business_unit_product_id_auth_method bupiam = new Business_unit_product_id_auth_method(); bupiam.PopulateFrom(id); bupiam.business_unit_party_id.Value = party.Variable; bupiam.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupiam); } Business_unit_purchasable_product bupp = new Business_unit_purchasable_product(); bupp.PopulateFrom(prod); bupp.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupp); foreach (var reason in prod.Reasons) { Business_unit_product_reason bupr = new Business_unit_product_reason(); bupr.PopulateFrom(reason); bupr.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupr); } foreach (var relationship in prod.Relationships) { Business_unit_product_relationship bupr = new Business_unit_product_relationship(); bupr.PopulateFrom(relationship); bupr.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupr); } foreach (var om in prod.OrderMethods) { Business_unit_product_order_method bupom = new Business_unit_product_order_method(); bupom.PopulateFrom(om); bupom.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupom); } foreach (var shippy in prod.ShippingMethods) { Business_unit_product_delivery_method bupdm = new Business_unit_product_delivery_method(); bupdm.PopulateFrom(shippy); bupdm.business_unit_delivery_product_id.Value = _services[shippy.Service]; bupdm.business_unit_product_id.Value = bup.Variable; _sqlEntities.Add(bupdm); } foreach (var c in prod.Contents) { Template t = new Template(); t.PopulateFrom(c); t.template_text.Value = _contentTexts[c.Text]; SqlVariable templateVariable = AddUniqueSqlEntity(t); Content_assignment ca = new Content_assignment(); ca.PopulateFrom(c); ca.attached_to_type_cd_id.Value = GSC(SystemCodeType.SYSTEM_OBJECT_TYPE, "business unit product"); ca.template_id.Value = templateVariable; ca.attached_to_id.Value = bup.Variable; ca.GenVariable(); _sqlEntities.Add(ca); } foreach (var ca in prod.CoverageAreas) { Business_unit_product_coverage_area bupca = new Business_unit_product_coverage_area(); bupca.PopulateFrom(ca); bupca.business_unit_product_id.Value = bup.Variable; bupca.coverage_area_id.Value = _coverageAreas[ca]; _sqlEntities.Add(bupca); } }