/// <summary>
		/// Patch changes
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this dataModel.StoreShippingMethod source, dataModel.StoreShippingMethod target)
		{
			if (target == null)
				throw new ArgumentNullException("target");
			var patchInjectionPolicy = new PatchInjection<dataModel.StoreShippingMethod>(x => x.LogoUrl, x => x.Name,
																		   x => x.Description, x => x.Priority,
																		   x => x.IsActive);
			target.InjectFrom(patchInjectionPolicy, source);
		}
Esempio n. 2
0
		/// <summary>
		/// Patch changes
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this dataModel.Store source, dataModel.Store target)
		{
			if (target == null)
				throw new ArgumentNullException("target");
			var patchInjectionPolicy = new PatchInjection<dataModel.Store>(x=>x.FulfillmentCenterId, x=>x.ReturnsFulfillmentCenterId, 
																		   x => x.AdminEmail, x => x.Catalog,
																		   x => x.Country, x => x.CreditCardSavePolicy,
																		   x => x.DefaultCurrency, x => x.DefaultLanguage,
																		   x => x.Description, x => x.DisplayOutOfStock,
																		   x => x.Email, x => x.Name, x => x.Region, x => x.SecureUrl,
																		   x => x.TimeZone, x => x.Url, x=>x.StoreState);
			target.InjectFrom(patchInjectionPolicy, source);


			if (!source.Languages.IsNullCollection())
			{
				var languageComparer = AnonymousComparer.Create((dataModel.StoreLanguage x) => x.LanguageCode);
				source.Languages.Patch(target.Languages, languageComparer, 
									  (sourceLang, targetLang) =>  targetLang.LanguageCode = sourceLang.LanguageCode);
			}
			if (!source.Currencies.IsNullCollection())
			{
				var currencyComparer = AnonymousComparer.Create((dataModel.StoreCurrency x) => x.CurrencyCode);
				source.Currencies.Patch(target.Currencies, currencyComparer,
									  (sourceCurrency, targetCurrency) => targetCurrency.CurrencyCode = sourceCurrency.CurrencyCode);
			}
			if (!source.PaymentMethods.IsNullCollection())
			{
				var paymentComparer = AnonymousComparer.Create((dataModel.StorePaymentMethod x) => x.Code);
				source.PaymentMethods.Patch(target.PaymentMethods, paymentComparer,
									  (sourceMethod, targetMethod) => sourceMethod.Patch(targetMethod));
			}
			if (!source.ShippingMethods.IsNullCollection())
			{
				var shippingComparer = AnonymousComparer.Create((dataModel.StoreShippingMethod x) => x.Code);
				source.ShippingMethods.Patch(target.ShippingMethods, shippingComparer,
									  (sourceMethod, targetMethod) => sourceMethod.Patch(targetMethod));
			}
            if (!source.TaxProviders.IsNullCollection())
            {
                var shippingComparer = AnonymousComparer.Create((dataModel.StoreTaxProvider x) => x.Code);
                source.TaxProviders.Patch(target.TaxProviders, shippingComparer,
                                      (sourceProvider, targetProvider) => sourceProvider.Patch(targetProvider));
            }
        }