public coreModel.Store Create(coreModel.Store store)
        {
            var dbStore = store.ToDataModel();

            using (var repository = _repositoryFactory())
            {
                repository.Add(dbStore);
                CommitChanges(repository);
            }

            //Need add seo separately
            if (store.SeoInfos != null)
            {
                foreach (var seoInfo in store.SeoInfos)
                {
                    seoInfo.ObjectId   = dbStore.Id;
                    seoInfo.ObjectType = typeof(coreModel.Store).Name;
                    _commerceService.UpsertSeo(seoInfo);
                }
            }

            //Deep save settings
            SaveObjectSettings(_settingManager, store);

            var retVal = GetById(store.Id);

            return(retVal);
        }
示例#2
0
        public coreModel.Store GetById(string id)
        {
            var cacheKey = CacheKey.Create("StoreModule", "GetById", id);

            return(_cacheManager.Get(cacheKey, () =>
            {
                coreModel.Store retVal = null;
                using (var repository = _repositoryFactory())
                {
                    var entity = repository.GetStoreById(id);

                    if (entity != null)
                    {
                        //Load original typed shipping method and populate it  personalized information from db
                        retVal = entity.ToCoreModel(_shippingService.GetAllShippingMethods(), _paymentService.GetAllPaymentMethods());

                        var fulfillmentCenters = _commerceService.GetAllFulfillmentCenters().ToList();
                        retVal.ReturnsFulfillmentCenter = fulfillmentCenters.FirstOrDefault(x => x.Id == entity.ReturnsFulfillmentCenterId);
                        retVal.FulfillmentCenter = fulfillmentCenters.FirstOrDefault(x => x.Id == entity.FulfillmentCenterId);
                        retVal.SeoInfos = _commerceService.GetObjectsSeo(new[] { id }).ToList();

                        LoadObjectSettings(_settingManager, retVal);
                    }
                }
                return retVal;
            }));
        }
示例#3
0
        public coreModel.Store Create(coreModel.Store store)
        {
            var dbStore = store.ToDataModel();

            using (var repository = _repositoryFactory())
            {
                repository.Add(dbStore);
                CommitChanges(repository);
                store.Id = dbStore.Id;
            }

            //Need add seo separately
            _commerceService.UpsertSeoForObjects(new[] { store });

            //Deep save properties
            _dynamicPropertyService.SaveDynamicPropertyValues(store);
            //Deep save settings
            _settingManager.SaveEntitySettingsValues(store);

            //Invalidate module cache region
            _cacheManager.ClearRegion("StoreModuleRegion");

            var retVal = GetById(store.Id);

            return(retVal);
        }
        public coreModel.Store Create(coreModel.Store store)
        {
            var dbStore = store.ToDataModel();

            using (var repository = _repositoryFactory())
            {
                repository.Add(dbStore);
                CommitChanges(repository);
            }

            //Need add seo separately
            if (store.SeoInfos != null)
            {
                foreach (var seoInfo in store.SeoInfos)
                {
                    seoInfo.ObjectId   = dbStore.Id;
                    seoInfo.ObjectType = typeof(coreModel.Store).Name;
                    _commerceService.UpsertSeo(seoInfo);
                }
            }

            //Deep save properties
            _dynamicPropertyService.SaveDynamicPropertyValues(store);
            //Deep save settings
            _settingManager.SaveEntitySettingsValues(store);

            //Reset cache
            var cacheKey = CacheKey.Create("StoreModule", "GetById", store.Id);

            _cacheManager.Remove(cacheKey);

            var retVal = GetById(store.Id);

            return(retVal);
        }
        private IEnumerable <CatalogItem> InnerGetProductsByIds(storeModel.Store store, String[] ids, ItemResponseGroup responseGroup)
        {
            var retVal   = new List <CatalogItem>();
            var products = _itemService.GetByIds(ids, responseGroup);            //.Where(p=>p.CatalogId == store.Catalog);

            foreach (var product in products)
            {
                coreModel.Property[] properties = null;
                if ((responseGroup & ItemResponseGroup.ItemProperties) == ItemResponseGroup.ItemProperties)
                {
                    properties = GetAllProductProperies(product);
                }

                if (product != null)
                {
                    var webModelProduct = product.ToWebModel(_blobUrlResolver, properties);
                    if (product.CategoryId != null)
                    {
                        var category = _categoryService.GetById(product.CategoryId);
                        webModelProduct.Outline = string.Join("/", category.Parents.Select(x => x.Id)) + "/" + category.Id;
                    }
                    retVal.Add(webModelProduct);
                }
            }

            if ((responseGroup & ItemResponseGroup.Inventory) == ItemResponseGroup.Inventory)
            {
                this.PopulateInventory(store.FulfillmentCenter, retVal);
            }
            return(retVal);
        }
示例#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);
        }
示例#7
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;
        }
示例#8
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);
        }
        public static dataModel.Store ToDataModel(this coreModel.Store store)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }

            var retVal = new dataModel.Store();

            retVal.InjectFrom(store);
            retVal.StoreState = (int)store.StoreState;

            if (store.DefaultCurrency != null)
            {
                retVal.DefaultCurrency = store.DefaultCurrency.ToString();
            }
            if (store.FulfillmentCenter != null)
            {
                retVal.FulfillmentCenterId = store.FulfillmentCenter.Id;
            }
            if (store.ReturnsFulfillmentCenter != null)
            {
                retVal.ReturnsFulfillmentCenterId = store.ReturnsFulfillmentCenter.Id;
            }
            if (store.Languages != null)
            {
                retVal.Languages = new ObservableCollection <dataModel.StoreLanguage>(store.Languages.Select(x => new dataModel.StoreLanguage
                {
                    LanguageCode = x,
                    StoreId      = retVal.Id
                }));
            }

            if (store.Currencies != null)
            {
                retVal.Currencies = new ObservableCollection <dataModel.StoreCurrency>(store.Currencies.Select(x => new dataModel.StoreCurrency
                {
                    CurrencyCode = x.ToString(),
                    StoreId      = retVal.Id
                }));
            }

            if (store.ShippingMethods != null)
            {
                retVal.ShippingMethods = new ObservableCollection <dataModel.StoreShippingMethod>(store.ShippingMethods.Select(x => x.ToDataModel()));
            }
            if (store.PaymentMethods != null)
            {
                retVal.PaymentMethods = new ObservableCollection <dataModel.StorePaymentMethod>(store.PaymentMethods.Select(x => x.ToDataModel()));
            }
            if (store.TaxProviders != null)
            {
                retVal.TaxProviders = new ObservableCollection <dataModel.StoreTaxProvider>(store.TaxProviders.Select(x => x.ToDataModel()));
            }
            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);
        }
示例#11
0
        public static webModel.Store ToWebModel(this coreModel.Store store)
        {
            var retVal = new webModel.Store();

            retVal.InjectFrom(store);

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

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


            if (store.Settings != null)
            {
                retVal.Settings = new PropertyDictionary();

                foreach (var propValueGroup in store.Settings.GroupBy(x => x.Name))
                {
                    var val = propValueGroup.Select(g => g.Value).SingleOrDefault();
                    if (val != null)
                    {
                        retVal.Settings.Add(propValueGroup.Key, val);
                    }
                }
            }

            if (store.SeoInfos != null)
            {
                retVal.Seo = store.SeoInfos.Select(x => x.ToWebModel()).ToArray();
            }

            if (store.PaymentMethods != null)
            {
                var paymentMethods = store.PaymentMethods.Where(p => p.IsActive).Select(p => new PaymentMethod
                {
                    GatewayCode = p.Code,
                    Name        = p.Description,
                    IconUrl     = p.LogoUrl,
                    Type        = p.PaymentMethodType.ToString(),
                    Group       = p.PaymentMethodGroupType.ToString(),
                    Description = p.Description,
                    Priority    = p.Priority
                }).ToArray();

                retVal.PaymentMethods = paymentMethods;
            }

            return(retVal);
        }
示例#12
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;

		}
示例#13
0
        private static FilteredBrowsing GetFilteredBrowsing(Store store)
        {
            FilteredBrowsing result = null;

            var filterSettingValue = store.GetDynamicPropertyValue("FilteredBrowsing", string.Empty);

            if (!string.IsNullOrEmpty(filterSettingValue))
            {
                var reader = new StringReader(filterSettingValue);
                var serializer = new XmlSerializer(typeof(FilteredBrowsing));
                result = serializer.Deserialize(reader) as FilteredBrowsing;
            }

            return result;
        }
示例#14
0
        /// <summary>
        ///     Gets the store browse filters.
        /// </summary>
        /// <param name="store">The store.</param>
        /// <returns>Filtered browsing</returns>
        private FilteredBrowsing GetStoreBrowseFilters(Store store)
        {
            if (store == null || store.Settings == null)
                return null;

            var filterSetting = store.Settings.FirstOrDefault(x => x.Name == "FilteredBrowsing");
            if (filterSetting != null && filterSetting.Value != null)
            {
                var serializer = new XmlSerializer(typeof(FilteredBrowsing));
                var reader = new StringReader(filterSetting.Value.ToString());
                var browsing = serializer.Deserialize(reader) as FilteredBrowsing;
                return browsing;
            }

            return null;
        }
示例#15
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;
		}
示例#16
0
        public static webModel.Store ToWebModel(this coreModel.Store store)
        {
            var retVal = new webModel.Store();

            retVal.InjectFrom(store);

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

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


            if (store.Settings != null)
            {
                retVal.Settings = new PropertyDictionary();

                foreach (var propValueGroup in store.Settings.GroupBy(x => x.Name))
                {
                    var val = propValueGroup.Select(g => g.Value).SingleOrDefault();
                    if (val != null)
                    {
                        retVal.Settings.Add(propValueGroup.Key, val);
                    }
                }
            }

            if (store.SeoInfos != null)
            {
                retVal.Seo = store.SeoInfos.Select(x => x.ToWebModel()).ToArray();
            }

            return(retVal);
        }
示例#17
0
        public coreModel.Store GetById(string id)
        {
            coreModel.Store retVal = null;
            using (var repository = _repositoryFactory())
            {
                var entity = repository.GetStoreById(id);

                if (entity != null)
                {
                    //Load original typed shipping method and populate it  personalized information from db
                    retVal = entity.ToCoreModel(_shippingService.GetAllShippingMethods(), _paymentService.GetAllPaymentMethods(), _taxService.GetAllTaxProviders());

                    var fulfillmentCenters = _commerceService.GetAllFulfillmentCenters().ToList();
                    retVal.ReturnsFulfillmentCenter = fulfillmentCenters.FirstOrDefault(x => x.Id == entity.ReturnsFulfillmentCenterId);
                    retVal.FulfillmentCenter        = fulfillmentCenters.FirstOrDefault(x => x.Id == entity.FulfillmentCenterId);

                    _commerceService.LoadSeoForObjects(new[] { retVal });
                    _settingManager.LoadEntitySettingsValues(retVal);
                    _dynamicPropertyService.LoadDynamicPropertyValues(retVal);
                }
            }
            return(retVal);
        }
        private static void SetFilteredBrowsingAttributes(Store store, AttributeFilter[] attributes)
        {
            var browsing = GetFilteredBrowsing(store) ?? new FilteredBrowsing();
            browsing.Attributes = attributes;
            var serializer = new XmlSerializer(typeof(FilteredBrowsing));
            var builder = new StringBuilder();
            var writer = new StringWriter(builder);
            serializer.Serialize(writer, browsing);
            var value = builder.ToString();

            var property = store.DynamicProperties.FirstOrDefault(p => p.Name == _filteredBrowsingPropertyName);

            if (property == null)
            {
                property = new DynamicObjectProperty { Name = _filteredBrowsingPropertyName };
                store.DynamicProperties.Add(property);
            }

            property.Values = new List<DynamicPropertyObjectValue>(new[] { new DynamicPropertyObjectValue { Value = value } });
        }
        private static string[] GetSelectedFilterProperties(Store store)
        {
            var result = new List<string>();

            var browsing = GetFilteredBrowsing(store);
            if (browsing != null && browsing.Attributes != null)
            {
                result.AddRange(browsing.Attributes.Select(a => a.Key));
            }

            return result.ToArray();
        }
示例#20
0
 public IHttpActionResult Update(coreModel.Store store)
 {
     CheckCurrentUserHasPermissionForObjects(StorePredefinedPermissions.Update, store);
     _storeService.Update(new[] { store });
     return(StatusCode(HttpStatusCode.NoContent));
 }
		private Dictionary<string, string> GetConfigMap(Store store)
		{
			var retVal = new Dictionary<string, string>();

			retVal.Add(PaypalModeConfigSettingName, Mode);
			retVal.Add(PaypalUsernameConfigSettingName, APIUsername);
			retVal.Add(PaypalPasswordConfigSettingName, APIPassword);
			retVal.Add(PaypalSignatureConfigSettingName, APISignature);

			return retVal;
		}
		private SetExpressCheckoutReq CreatePaypalRequest(CustomerOrder order, Store store, PaymentIn payment)
		{
			var retVal = new SetExpressCheckoutReq();

			var request = new SetExpressCheckoutRequestType();

			var ecDetails = new SetExpressCheckoutRequestDetailsType
			{
				CallbackTimeout = "3",
				ReturnURL = string.Format("{0}/{1}?cancel=false&orderId={2}", store.Url, PaypalPaymentRedirectRelativePath, order.Id),
				CancelURL = string.Format("{0}/{1}?cancel=true&orderId={2}", store.Url, PaypalPaymentRedirectRelativePath, order.Id)
			};

			if (PaypalPaymentModeStoreSetting.Equals("BankCard"))
			{
				ecDetails.SolutionType = SolutionTypeType.SOLE;
				ecDetails.LandingPage = LandingPageType.BILLING;
			}
			else
			{
				ecDetails.SolutionType = SolutionTypeType.MARK;
				ecDetails.LandingPage = LandingPageType.LOGIN;
			}

			var currency = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), order.Currency.ToString());

			var billingAddress = order.Addresses.FirstOrDefault(s => s.AddressType == VirtoCommerce.Domain.Order.Model.AddressType.Billing);

			if (billingAddress != null)
				ecDetails.BuyerEmail = billingAddress.Email;
			else
				billingAddress = order.Addresses.FirstOrDefault();

			if (billingAddress != null && !string.IsNullOrEmpty(billingAddress.Email))
				ecDetails.BuyerEmail = billingAddress.Email;

			ecDetails.PaymentDetails.Add(GetPaypalPaymentDetail(currency, PaymentActionCodeType.SALE, payment));

			request.SetExpressCheckoutRequestDetails = ecDetails;

			retVal.SetExpressCheckoutRequest = request;

			return retVal;
		}
示例#23
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);
        }
示例#24
0
        public IHttpActionResult Create(coreModel.Store store)
        {
            var retVal = _storeService.Create(store);

            return(Ok(store));
        }