public StoreLocalizationStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory, IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory) : base(repositoryFactory, entityFactory, item) { _appConfigRepositoryFactory = appConfigRepositoryFactory; }
public StoreSeoViewModel(ILoginViewModel loginViewModel, IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory, IAppConfigEntityFactory appConfigEntityFactory, Store item, IEnumerable<string> languages) : base(appConfigRepositoryFactory, appConfigEntityFactory, item.DefaultLanguage, languages, item.StoreId, SeoUrlKeywordTypes.Store) { _loginViewModel = loginViewModel; _store = item; InitializePropertiesForViewing(); }
public StorePaymentsStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory, IRepositoryFactory<IPaymentMethodRepository> paymentRepositoryFactory) : base(repositoryFactory, entityFactory, item) { _paymentRepositoryFactory = paymentRepositoryFactory; _repositoryFactory = repositoryFactory; }
public StoreOverviewStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory, IRepositoryFactory<ICatalogRepository> catalogRepositoryFactory, IRepositoryFactory<ICountryRepository> countryRepositoryFactory, IRepositoryFactory<IFulfillmentCenterRepository> fulfillmentRepositoryFactory) : base(repositoryFactory, entityFactory, item) { _catalogRepositoryFactory = catalogRepositoryFactory; _countryRepositoryFactory = countryRepositoryFactory; _fulfillmetnRepositoryFactory = fulfillmentRepositoryFactory; }
/// <summary> /// Gets the store browse filters. /// </summary> /// <param name="store">The store.</param> /// <returns>Filtered browsing</returns> private FilteredBrowsing GetStoreBrowseFilters(Store store) { var filter = (from s in store.Settings where s.Name == "FilteredBrowsing" select s.LongTextValue).FirstOrDefault(); if (!string.IsNullOrEmpty(filter)) { var filterString = filter; var serializer = new XmlSerializer(typeof(FilteredBrowsing)); TextReader reader = new StringReader(filterString); var browsing = serializer.Deserialize(reader) as FilteredBrowsing; return browsing; } return null; }
public CreateStoreViewModel( IViewModelsFactory<IStoreOverviewStepViewModel> overviewVmFactory, IViewModelsFactory<IStoreLocalizationStepViewModel> localizationVmFactory, IViewModelsFactory<IStoreTaxesStepViewModel> taxesVmFactory, IViewModelsFactory<IStorePaymentsStepViewModel> paymentsVmFactory, IViewModelsFactory<IStoreNavigationStepViewModel> navigationVmFactory, Store item) { _overviewVmFactory = overviewVmFactory; _localizationVmFactory = localizationVmFactory; _taxesVmFactory = taxesVmFactory; _paymentsVmFactory = paymentsVmFactory; _navigationVmFactory = navigationVmFactory; CreateWizardSteps(item); }
private void CreateWizardSteps(Store item) { var itemParameter = new KeyValuePair<string, object>("item", item); var OverviewStepViewModel = _overviewVmFactory.GetViewModelInstance(itemParameter); var LocalizationStepViewModel = _localizationVmFactory.GetViewModelInstance(itemParameter); var TaxesStepViewModel = _taxesVmFactory.GetViewModelInstance(itemParameter); var PaymentsStepViewModel = _paymentsVmFactory.GetViewModelInstance(itemParameter); var NavigationStepViewModel = _navigationVmFactory.GetViewModelInstance(itemParameter); //var SeoStepViewModel = _seoVmFactory.GetViewModelInstance(itemParameter); RegisterStep(OverviewStepViewModel); RegisterStep(LocalizationStepViewModel); RegisterStep(TaxesStepViewModel); RegisterStep(PaymentsStepViewModel); RegisterStep(NavigationStepViewModel); //RegisterStep(SeoStepViewModel); }
public void Can_run_activity_validatelineitems() { var orderGroup = CreateCart(); orderGroup.OrderForms[0].LineItems[0].Catalog = "default"; orderGroup.OrderForms[0].LineItems[0].CatalogItemId = "v-9948444183"; orderGroup.OrderForms[0].LineItems[0].FulfillmentCenterId = "default"; orderGroup.OrderForms[0].LineItems[0].Quantity = 4; orderGroup.OrderForms[0].LineItems[1].Catalog = "default"; orderGroup.OrderForms[0].LineItems[1].CatalogItemId = "v-b000068ilf"; orderGroup.OrderForms[0].LineItems[1].FulfillmentCenterId = "default"; orderGroup.OrderForms[0].LineItems[1].Quantity = 10; var invAvailable = new Inventory { AllowBackorder = true, AllowPreorder = true, FulfillmentCenterId = "default", InStockQuantity = 10, Sku = "v-9948444183", ReservedQuantity = 1, Status = InventoryStatus.Enabled.GetHashCode(), BackorderQuantity = 5, PreorderQuantity = 3 }; var invNotAvailable = new Inventory { AllowBackorder = true, AllowPreorder = true, FulfillmentCenterId = "default", InStockQuantity = 14, Sku = "v-b000068ilf", ReservedQuantity = 10, BackorderQuantity = 10, Status = InventoryStatus.Enabled.GetHashCode(), PreorderQuantity = 4 }; var mockUnitOfWork = new Mock<IUnitOfWork>(); var repository = new Mock<IInventoryRepository>(); repository.Setup(x => x.Inventories).Returns(() => new[] { invAvailable, invNotAvailable }.AsQueryable()); repository.Setup(x => x.UnitOfWork).Returns(mockUnitOfWork.Object); repository.SetupAllProperties(); var item1 = new Product { ItemId = "v-9948444183", TrackInventory = true, IsActive = true, IsBuyable = true, StartDate = DateTime.UtcNow.AddDays(-1), EndDate = DateTime.UtcNow.AddDays(1) }; var item2 = new Product { ItemId = "v-b000068ilf", IsActive = true, IsBuyable = true, TrackInventory = true, StartDate = DateTime.UtcNow.AddDays(-1), EndDate = DateTime.UtcNow.AddDays(1) }; var catrepository = new Mock<ICatalogRepository>(); catrepository.Setup(x => x.Items).Returns(() => new Item[] { item1, item2 }.AsQueryable()); catrepository.Setup(x => x.UnitOfWork).Returns(mockUnitOfWork.Object); catrepository.SetupAllProperties(); var store = new Store { StoreId = orderGroup.StoreId, Catalog = orderGroup.OrderForms[0].LineItems[0].Catalog }; var storeRepository = new Mock<IStoreRepository>(); storeRepository.Setup(x => x.Stores).Returns(() => new[] { store }.AsQueryable()); var priceList = new Pricelist { PricelistId = "default", Currency = "USD" }; var priceList2 = new Pricelist { PricelistId = "sale", Currency = "USD" }; var prices = new[] { new Price { List = 100, Sale = 90, MinQuantity = 1, ItemId = "v-9948444183" , PricelistId = "default"}, new Price { List = 95, Sale = 85, MinQuantity = 5, ItemId = "v-9948444183", PricelistId = "default"}, new Price { List = 98, Sale = 88, MinQuantity = 1, ItemId = "v-9948444183" , PricelistId = "sale"}, new Price { List = 93, Sale = 83, MinQuantity = 5, ItemId = "v-9948444183", PricelistId = "sale"}, new Price { List = 60, Sale = 50, MinQuantity = 1, ItemId = "v-b000068ilf" , PricelistId = "default"}, new Price { List = 55, Sale = 45, MinQuantity = 5, ItemId = "v-b000068ilf", PricelistId = "default"}, new Price { List = 58, Sale = 48, MinQuantity = 1, ItemId = "v-b000068ilf" , PricelistId = "sale"}, new Price { List = 53, Sale = 43, MinQuantity = 5, ItemId = "v-b000068ilf", PricelistId = "sale"} }; var priceRepository = new Mock<IPricelistRepository>(); priceRepository.Setup(x => x.Pricelists).Returns(() => new[] { priceList2, priceList }.AsQueryable()); priceRepository.Setup(x => x.Prices).Returns(prices.AsQueryable); var customerService = new CustomerSessionService(); var session = customerService.CustomerSession; session.Currency = "USD"; session.Pricelists = new[] { "Sale", "Default" }; var currencyService = new CurrencyService(); var cacheRepository = new Mock<ICacheRepository>(); cacheRepository.SetupAllProperties(); var activity = new ValidateLineItemsActivity(repository.Object, catrepository.Object, storeRepository.Object, customerService, priceRepository.Object, currencyService, null, null, cacheRepository.Object); var result = InvokeActivity(activity, orderGroup); var order = result.OrderGroup; // now check totals // Order totals // Order form totals var form = order.OrderForms[0]; Assert.True(form.LineItems.Count == 2); Assert.True(form.LineItems[0].InStockQuantity == 9); Assert.True(form.LineItems[0].PreorderQuantity == 3); Assert.True(form.LineItems[0].ListPrice == 88); Assert.True(form.LineItems[1].ListPrice == 43); }
public StoreSettingsStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory, IViewModelsFactory<IStoreSettingViewModel> vmFactory) : base(repositoryFactory, entityFactory, item) { _settingVmFactory = vmFactory; }
public StoreTaxesStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory) : base(repositoryFactory, entityFactory, item) { _repositoryFactory = repositoryFactory; }
/// <summary> /// Returns true if there is only not closed store or current store override url /// </summary> /// <param name="dbStore"></param> /// <returns></returns> protected virtual bool IsStoreNeeded(Store dbStore) { if (StoreHelper.StoreClient.GetStores().Count(x => x.StoreState != (int)StoreState.Closed) <= 1) { return false; } if (dbStore != null) { return string.IsNullOrEmpty(dbStore.Url) && string.IsNullOrEmpty(dbStore.SecureUrl); } return true; }
/// <summary> /// Gets the store currency. /// </summary> /// <param name="context">The context.</param> /// <param name="store">current store</param> /// <returns> /// System.String. /// </returns> protected virtual string GetStoreCurrency(HttpContext context, Store store) { var currency = context.Request.QueryString["currency"]; if (String.IsNullOrEmpty(currency)) { currency = String.Empty; // try getting store from the cookie if (String.IsNullOrEmpty(currency)) { currency = StoreHelper.GetCookieValue(CurrencyCookie); } // try getting default store from settings if (String.IsNullOrEmpty(currency)) { currency = store.DefaultCurrency; } } //if currency is invalid use dafault else if (!store.Currencies.Any(c => c.CurrencyCode.Equals(currency, StringComparison.OrdinalIgnoreCase))) { currency = store.DefaultCurrency; } return currency.ToUpperInvariant(); }
/// <summary> /// Determines whether [is store visible] [the specified store]. /// </summary> /// <param name="store">The store.</param> /// <returns><c>true</c> if [is store visible] [the specified store]; otherwise, <c>false</c>.</returns> private bool IsStoreVisible(Store store) { if (UserHelper.CustomerSession.IsRegistered) { string errorMessage; return StoreHelper.IsUserAuthorized(UserHelper.CustomerSession.Username, store.StoreId, out errorMessage); } return store.StoreState == StoreState.Open.GetHashCode() || store.StoreState == StoreState.RestrictedAccess.GetHashCode(); }
public StoreNavigationStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory) : base(repositoryFactory, entityFactory, item) { }
protected virtual bool IsLanguageNeeded(Store dbStore) { if (dbStore != null) { return dbStore.Languages.Count > 1; } return true; }
/// <summary> /// Gets the store all filters. /// </summary> /// <param name="store">The store.</param> /// <returns>ISearchFilter[][].</returns> private ISearchFilter[] GetStoreAllFilters(Store store) { var filters = new List<ISearchFilter>(); var catalogClient = ClientContext.Clients.CreateCatalogClient(); // get category filters var children = catalogClient.GetChildCategoriesById(_customerSession.CustomerSession.CategoryId); if (children != null) { var categoryFilter = new CategoryFilter { Key = "__outline" }; var listOfValues = (from child in children.OfType<Category>() let outline = String.Format("{0}*", catalogClient.BuildCategoryOutline(_customerSession.CustomerSession.CatalogId, child)) select new CategoryFilterValue {Id = child.CategoryId, Outline = outline, Name = child.DisplayName()}).ToList(); // add filters only if found any if (listOfValues.Count > 0) { categoryFilter.Values = listOfValues.ToArray(); filters.Add(categoryFilter); } /* var categoryFilter = new AttributeFilter{ IsLocalized = false, Key = "__outline"}; var listOfValues = new List<AttributeFilterValue>(); foreach (var child in children.OfType<Category>()) { var outline = String.Format("{0}*", catalogClient.BuildCategoryOutline(_customerSession.CustomerSession.CatalogId, child)); var val = new AttributeFilterValue() { Id = outline, Value = outline }; listOfValues.Add(val); } // add filters only if found any if (listOfValues.Count > 0) { categoryFilter.Values = listOfValues.ToArray(); filters.Add(categoryFilter); } * */ } var browsing = GetStoreBrowseFilters(store); if (browsing != null) { if (browsing.Attributes != null) { filters.AddRange(browsing.Attributes); } if (browsing.AttributeRanges != null) { filters.AddRange(browsing.AttributeRanges); } if (browsing.Prices != null) { filters.AddRange(browsing.Prices); } } return filters.ToArray(); }
/// <summary> /// Gets the store all filters. /// </summary> /// <param name="store">The store.</param> /// <returns>ISearchFilter[][].</returns> private ISearchFilter[] GetStoreAllFilters(Store store) { var filters = new List<ISearchFilter>(); var browsing = GetStoreBrowseFilters(store); if (browsing != null) { if (browsing.Attributes != null) { filters.AddRange(browsing.Attributes); } if (browsing.AttributeRanges != null) { filters.AddRange(browsing.AttributeRanges); } if (browsing.Prices != null) { filters.AddRange(browsing.Prices); } } return filters.ToArray(); }
/// <summary> /// Initializes a new instance of the <see cref="SearchHelper"/> class. /// </summary> /// <param name="store">The store.</param> public SearchHelper(Store store) { _store = store; }
private bool IsValidStoreLanguage(Store dbStore, string lang) { try { if (dbStore == null) { return false; } var culture = lang.ToSpecificLangCode(); if (!dbStore.Languages.Any(l => l.LanguageCode.ToSpecificLangCode().Equals(culture, StringComparison.InvariantCultureIgnoreCase))) { //Store does not support this language return false; } } catch { //Language is not valid return false; } return true; }
public StoreLinkedStoresStepViewModel(IStoreEntityFactory entityFactory, Store item, IRepositoryFactory<IStoreRepository> repositoryFactory) : base(repositoryFactory, entityFactory, item) { }