Example #1
0
        public static webModel.ShippingMethod ToWebModel(this coreModel.ShippingMethod shippingMethod)
        {
            var retVal = new webModel.ShippingMethod();

            retVal.InjectFrom(shippingMethod);
            return(retVal);
        }
Example #2
0
		/// <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.ShippingMethod ToWebModel(this coreModel.ShippingMethod method)
        {
            var retVal = new webModel.ShippingMethod();

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

            return(retVal);
        }
        public static dataModel.StoreShippingMethod ToDataModel(this coreModel.ShippingMethod shippingMethod)
        {
            if (shippingMethod == null)
            {
                throw new ArgumentNullException("shippingMethod");
            }

            var retVal = new dataModel.StoreShippingMethod();

            retVal.InjectFrom(shippingMethod);

            return(retVal);
        }