public static webModel.PaymentMethod ToWebModel(this coreModel.PaymentMethod method)
        {
            var retVal = new webModel.PaymentMethod();

            retVal.InjectFrom(method);

            return(retVal);
        }
        public static webModel.PaymentMethod ToWebModel(this coreModel.PaymentMethod paymentMethod)
        {
            var retVal = new webModel.PaymentMethod();

            retVal.InjectFrom(paymentMethod);
            retVal.PaymentMethodGroupType = paymentMethod.PaymentMethodGroupType;
            retVal.PaymentMethodType      = paymentMethod.PaymentMethodType;
            retVal.IconUrl = paymentMethod.LogoUrl;
            return(retVal);
        }
		/// <summary>
		/// Converting to model type
		/// </summary>
		/// <param name="catalogBase"></param>
		/// <returns></returns>
		public static coreModel.Store ToCoreModel(this dataModel.Store dbStore, ShippingMethod[] shippingMethods, PaymentMethod[] paymentMethods, TaxProvider[] taxProviders)
		{
			if (dbStore == null)
				throw new ArgumentNullException("dbStore");

			var retVal = new coreModel.Store();
			retVal.InjectFrom(dbStore);
	

			if(dbStore.DefaultCurrency != null)
			{
				retVal.DefaultCurrency = (CurrencyCodes?)Enum.Parse(typeof(CurrencyCodes), dbStore.DefaultCurrency, true);
			}
			retVal.StoreState = (coreModel.StoreState)dbStore.StoreState;
			
			retVal.Languages = dbStore.Languages.Select(x => x.LanguageCode).ToList();
			retVal.Currencies = dbStore.Currencies.Select(x => (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), x.CurrencyCode, true)).ToList();
		
			//Payment methods need return only contains in registered
			retVal.PaymentMethods = paymentMethods;
			foreach (var paymentMethod in paymentMethods)
			{
				var dbStoredPaymentMethod = dbStore.PaymentMethods.FirstOrDefault(x => x.Code == paymentMethod.Code);
				if (dbStoredPaymentMethod != null)
				{
					paymentMethod.InjectFrom(dbStoredPaymentMethod);
				}
			}

			//Shipping methods need return only contains in registered
			retVal.ShippingMethods = shippingMethods;
			foreach (var shippingMethod in shippingMethods)
			{
				var dbStoredShippingMethod = dbStore.ShippingMethods.FirstOrDefault(x => x.Code == shippingMethod.Code);
				if(dbStoredShippingMethod != null)
				{
					shippingMethod.InjectFrom(dbStoredShippingMethod);
				}
			}

            //Tax providers need return only contains in registered
            retVal.TaxProviders = taxProviders;
            foreach (var taxProvider in taxProviders)
            {
                var dbStoredTaxProvider = dbStore.TaxProviders.FirstOrDefault(x => x.Code == taxProvider.Code);
                if (dbStoredTaxProvider != null)
                {
                    taxProvider.InjectFrom(dbStoredTaxProvider);
                }
            }
            return retVal;

		}
        public static webModel.PaymentMethod ToWebModel(this coreModel.PaymentMethod method)
        {
            var retVal = new webModel.PaymentMethod();

            retVal.InjectFrom(method);
            if (method.Settings != null)
            {
                retVal.Settings = method.Settings.Select(x => x.ToWebModel()).ToList();
            }

            return(retVal);
        }
        public static dataModel.StorePaymentMethod ToDataModel(this coreModel.PaymentMethod paymentMethod)
        {
            if (paymentMethod == null)
            {
                throw new ArgumentNullException("paymentMethod");
            }

            var retVal = new dataModel.StorePaymentMethod();

            retVal.InjectFrom(paymentMethod);

            return(retVal);
        }
        public static webModel.PaymentMethod ToWebModel(this coreModel.PaymentMethod paymentMethod)
        {
            var retVal = new webModel.PaymentMethod();

            retVal.InjectFrom(paymentMethod);

            retVal.GatewayCode           = paymentMethod.Code;
            retVal.Name                  = paymentMethod.Description;
            retVal.IconUrl               = paymentMethod.LogoUrl;
            retVal.Type                  = paymentMethod.PaymentMethodType.ToString();
            retVal.Group                 = paymentMethod.PaymentMethodGroupType.ToString();
            retVal.Description           = paymentMethod.Description;
            retVal.Priority              = paymentMethod.Priority;
            retVal.IsAvailableForPartial = paymentMethod.IsAvailableForPartial;
            if (paymentMethod.Settings != null)
            {
                retVal.Settings = paymentMethod.Settings.Where(x => x.ValueType != SettingValueType.SecureString).ToList();
            }

            return(retVal);
        }
        public static coreModel.PaymentMethod ToCoreModel(this webModel.PaymentMethod webMethod, coreModel.PaymentMethod paymentMethod)
        {
            var retVal = paymentMethod;

            retVal.InjectFrom(webMethod);
            if (webMethod.Settings != null)
            {
                retVal.Settings = webMethod.Settings.Select(x => x.ToCoreModel()).ToList();
            }
            return(retVal);
        }