public void CreateNewStore()
        {
            var controller = GetStoreController();
            var store = new Store
            {
                Id = "testStore",
                Name = "testStore",
                Catalog = "catalog",
                Currencies = new[] { CurrencyCodes.USD, CurrencyCodes.RUB },
                DefaultCurrency = CurrencyCodes.USD,
                Languages = new[] { "ru-ru", "en-us" },
                DefaultLanguage = "ru-ru",
                FulfillmentCenter = new FulfillmentCenter
                {
                    City = "New York",
                    CountryCode = "USA",
                    Line1 = "line1",
                    DaytimePhoneNumber = "+821291921",
                    CountryName = "USA",
                    Name = "Name",
                    StateProvince = "State",
                    PostalCode = "code"
                },
                //PaymentGateways = new string[] { "PayPal", "Clarna" },
                StoreState = Domain.Store.Model.StoreState.Open,
                Settings = new[] { new Setting { Name = "test", Value = "sss", ValueType = Platform.Core.Settings.SettingValueType.ShortText } }

            };
            var result = controller.Create(store) as OkNegotiatedContentResult<Store>;
            Assert.IsNotNull(result.Content);
        }
Example #2
0
        public IHttpActionResult Create(webModel.Store store)
        {
            var coreStore = store.ToCoreModel(_shippingService.GetAllShippingMethods(), _paymentService.GetAllPaymentMethods(), _taxService.GetAllTaxProviders());
            var retVal    = _storeService.Create(coreStore);

            return(Ok(retVal.ToWebModel()));
        }
        public IHttpActionResult Update(webModel.Store store)
        {
            var coreStore = store.ToCoreModel(_shippingService.GetAllShippingMethods(), _paymentService.GetAllPaymentMethods());

            _storeService.Update(new coreModel.Store[] { coreStore });
            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
		public static webModel.Store ToWebModel(this coreModel.Store store)
		{
			var retVal = new webModel.Store();
			retVal.InjectFrom(store);
			retVal.SeoInfos = store.SeoInfos;
			retVal.DefaultCurrency = store.DefaultCurrency;
			retVal.StoreState = store.StoreState;
			if (store.Settings != null)
				retVal.Settings = store.Settings.Select(x => x.ToWebModel()).ToList();
			if (store.ShippingMethods != null)
				retVal.ShippingMethods = store.ShippingMethods.Select(x => x.ToWebModel()).ToList();
			if (store.PaymentMethods != null)
				retVal.PaymentMethods = store.PaymentMethods.Select(x => x.ToWebModel()).ToList();

			if (store.Languages != null)
				retVal.Languages = store.Languages;
			if (store.Currencies != null)
				retVal.Currencies = store.Currencies;
			if (store.ReturnsFulfillmentCenter != null)
				retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToWebModel();
			if (store.FulfillmentCenter != null)
				retVal.FulfillmentCenter = store.FulfillmentCenter.ToWebModel();

			return retVal;
		}
Example #5
0
        public IHttpActionResult Update(webModel.Store store)
        {
            var coreStore = store.ToCoreModel(_shippingService.GetAllShippingMethods(), _paymentService.GetAllPaymentMethods(), _taxService.GetAllTaxProviders());

            CheckCurrentUserHasPermissionForObjects(StorePredefinedPermissions.Update, coreStore);
            _storeService.Update(new[] { coreStore });
            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #6
0
        public static webModel.Store ToWebModel(this coreModel.Store store)
        {
            var retVal = new webModel.Store();

            retVal.InjectFrom(store);
            retVal.SeoInfos          = store.SeoInfos;
            retVal.DefaultCurrency   = store.DefaultCurrency;
            retVal.StoreState        = store.StoreState;
            retVal.DynamicProperties = store.DynamicProperties;

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

            if (store.ShippingMethods != null)
            {
                retVal.ShippingMethods = store.ShippingMethods.Select(x => x.ToWebModel()).ToList();
            }

            if (store.PaymentMethods != null)
            {
                retVal.PaymentMethods = store.PaymentMethods.Select(x => x.ToWebModel()).ToList();
            }

            if (store.TaxProviders != null)
            {
                retVal.TaxProviders = store.TaxProviders.Select(x => x.ToWebModel()).ToList();
            }

            if (store.Languages != null)
            {
                retVal.Languages = store.Languages;
            }

            if (store.Currencies != null)
            {
                retVal.Currencies = store.Currencies;
            }

            if (store.TrustedGroups != null)
            {
                retVal.TrustedGroups = store.TrustedGroups;
            }

            if (store.ReturnsFulfillmentCenter != null)
            {
                retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToWebModel();
            }

            if (store.FulfillmentCenter != null)
            {
                retVal.FulfillmentCenter = store.FulfillmentCenter.ToWebModel();
            }


            return(retVal);
        }
Example #7
0
        public static coreModel.Store ToCoreModel(this webModel.Store store, ShippingMethod[] shippingMethods, PaymentMethod[] paymentMethods)
        {
            var retVal = new coreModel.Store();

            retVal.InjectFrom(store);
            retVal.SeoInfos   = store.SeoInfos;
            retVal.StoreState = store.StoreState;
            if (store.Settings != null)
            {
                retVal.Settings = store.Settings.Select(x => x.ToCoreModel()).ToList();
            }

            if (store.ShippingMethods != null)
            {
                retVal.ShippingMethods = new List <ShippingMethod>();
                foreach (var shippingMethod in shippingMethods)
                {
                    var webShippingMethod = store.ShippingMethods.FirstOrDefault(x => x.Code == shippingMethod.Code);
                    if (webShippingMethod != null)
                    {
                        retVal.ShippingMethods.Add(webShippingMethod.ToCoreModel(shippingMethod));
                    }
                }
            }

            if (store.PaymentMethods != null)
            {
                retVal.PaymentMethods = new List <PaymentMethod>();
                foreach (var paymentMethod in paymentMethods)
                {
                    var webPaymentMethod = store.PaymentMethods.FirstOrDefault(x => x.Code == paymentMethod.Code);
                    if (webPaymentMethod != null)
                    {
                        retVal.PaymentMethods.Add(webPaymentMethod.ToCoreModel(paymentMethod));
                    }
                }
            }

            if (store.Languages != null)
            {
                retVal.Languages = store.Languages;
            }
            if (store.Currencies != null)
            {
                retVal.Currencies = store.Currencies;
            }
            if (store.ReturnsFulfillmentCenter != null)
            {
                retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToCoreModel();
            }
            if (store.FulfillmentCenter != null)
            {
                retVal.FulfillmentCenter = store.FulfillmentCenter.ToCoreModel();
            }


            return(retVal);
        }
Example #8
0
        public static coreModel.Store ToCoreModel(this webModel.Store store, ShippingMethod[] shippingMethods, PaymentMethod[] paymentMethods, TaxProvider[] taxProviders)
        {
            var retVal = new coreModel.Store();

            retVal.InjectFrom(store);
            retVal.SeoInfos          = store.SeoInfos;
            retVal.StoreState        = store.StoreState;
            retVal.DynamicProperties = store.DynamicProperties;

            if (store.ShippingMethods != null)
            {
                retVal.ShippingMethods = new List <ShippingMethod>();
                foreach (var shippingMethod in shippingMethods)
                {
                    var webShippingMethod = store.ShippingMethods.FirstOrDefault(x => x.Code == shippingMethod.Code);
                    if (webShippingMethod != null)
                    {
                        retVal.ShippingMethods.Add(webShippingMethod.ToCoreModel(shippingMethod));
                    }
                }
            }

            if (store.PaymentMethods != null)
            {
                retVal.PaymentMethods = new List <PaymentMethod>();
                foreach (var paymentMethod in paymentMethods)
                {
                    var webPaymentMethod = store.PaymentMethods.FirstOrDefault(x => x.Code == paymentMethod.Code);
                    if (webPaymentMethod != null)
                    {
                        retVal.PaymentMethods.Add(webPaymentMethod.ToCoreModel(paymentMethod));
                    }
                }
            }

            if (store.TaxProviders != null)
            {
                retVal.TaxProviders = new List <TaxProvider>();
                foreach (var taxProvider in taxProviders)
                {
                    var webTaxProvider = store.TaxProviders.FirstOrDefault(x => x.Code == taxProvider.Code);
                    if (webTaxProvider != null)
                    {
                        retVal.TaxProviders.Add(webTaxProvider.ToCoreModel(taxProvider));
                    }
                }
            }

            if (store.Languages != null)
            {
                retVal.Languages = store.Languages;
            }
            if (store.Currencies != null)
            {
                retVal.Currencies = store.Currencies;
            }
            if (store.ReturnsFulfillmentCenter != null)
            {
                retVal.ReturnsFulfillmentCenter = store.ReturnsFulfillmentCenter.ToCoreModel();
            }
            if (store.FulfillmentCenter != null)
            {
                retVal.FulfillmentCenter = store.FulfillmentCenter.ToCoreModel();
            }

            return(retVal);
        }