public SearchItemViewModel(IRepositoryFactory <ICatalogRepository> catalogRepository, object catalogInfo, string searchType) { _catalogRepository = catalogRepository; SearchFilterItemTypes = new[] { "Variation", "Product", "Bundle", "Package", "Dynamic Kit" }; // TODO: move it to parameter constructor and refactor all calls // rp, quick hack, Inventory should contain not only products but variations... if (searchType == "Product...") { SearchFilterItemType = SearchFilterItemTypes[1]; CanChangeSearchItemType = true; } else { SearchFilterItemType = SearchFilterItemTypes.FirstOrDefault( x => x.Equals(searchType, StringComparison.OrdinalIgnoreCase)); if (SearchFilterItemType == null) { CanChangeSearchItemType = true; } } var catalogBase = catalogInfo as CatalogBase; if (catalogBase != null) { AvailableCatalogs = new List <CatalogBase> { catalogBase }; SearchCatalogId = AvailableCatalogs[0].CatalogId; } else { using (var repository = _catalogRepository.GetRepositoryInstance()) { var query = repository.Catalogs; if (!string.IsNullOrEmpty(catalogInfo as string)) { query = query.Where(x => x.CatalogId == (string)catalogInfo); SearchCatalogId = (string)catalogInfo; } else { query = query.OrderBy(x => x.Name); CanChangeSearchCatalog = true; } AvailableCatalogs = query.ToList(); } } SearchCommand = new DelegateCommand(DoSearch); ClearFiltersCommand = new DelegateCommand(DoClearFilters); ListItemsSource = new VirtualList <Item>(this, 20, SynchronizationContext.Current); SelectedItem = null; }
public ItemTypeSelectionStepViewModel() { SearchFilterItemTypes = new[] { new ItemTypeSelectionModel("Cart promotion", "Cart promotions are used to encourage shoppers to increase their order size by providing incentives, such as free shipping on orders over a certain sum."), new ItemTypeSelectionModel("Catalog promotion", "Catalog promotions are used to make specific products and categories of products more attractive to shoppers through incentives, such as lowered pricing on a particular brand.") }; SearchFilterItemTypes.ToList().ForEach(x => { x.Value = x.Value.Localize(); x.Description = x.Description.Localize(); }); SelectedItemType = SearchFilterItemTypes[0].Value; OnPropertyChanged("SelectedItemType"); }