Esempio n. 1
0
 public CatalogImportJobHomeViewModel(
     IRepositoryFactory <IImportRepository> importRepository,
     IViewModelsFactory <ICreateImportJobViewModel> wizardVmFactory,
     IViewModelsFactory <IImportJobRunViewModel> runVmFactory,
     IViewModelsFactory <IImportJobViewModel> itemVmFactory,
     IImportJobEntityFactory entityFactory,
     IAuthenticationContext authContext,
     IImportService importService,
     SubTabsDefaultViewModel parentViewModel)
     : base(importRepository, wizardVmFactory, runVmFactory, itemVmFactory, entityFactory, authContext, importService, parentViewModel)
 {
     AvailableImporters = new[]
     {
         ImportEntityType.Product,
         ImportEntityType.Bundle,
         ImportEntityType.Category,
         ImportEntityType.Association,
         ImportEntityType.DynamicKit,
         ImportEntityType.Package,
         ImportEntityType.Sku,
         ImportEntityType.ItemRelation,
         ImportEntityType.ItemAsset,
         ImportEntityType.Seo
     };
     DefaultImporter = AvailableImporters.First().ToString();
 }
 public PricelistImportJobHomeViewModel(
     IRepositoryFactory <IImportRepository> importRepository,
     IViewModelsFactory <ICreateImportJobViewModel> wizardVmFactory,
     IViewModelsFactory <IImportJobRunViewModel> runVmFactory,
     IViewModelsFactory <IImportJobViewModel> itemVmFactory,
     IImportJobEntityFactory entityFactory,
     IAuthenticationContext authContext,
     IImportService importService,
     SubTabsDefaultViewModel parentViewModel)
     : base(importRepository, wizardVmFactory, runVmFactory, itemVmFactory, entityFactory, authContext, importService, parentViewModel)
 {
     AvailableImporters = new[]
     {
         ImportEntityType.Price
     };
     DefaultImporter = AvailableImporters.First().ToString();
 }
        public ManualImportViewModel PreSelect(int accountId, ImporterType importer)
        {
            var selectedAccount = AvailableAccounts.FirstOrDefault(x => x.Value == accountId.ToString(CultureInfo.InvariantCulture));

            if (selectedAccount != null)
            {
                selectedAccount.Selected = true;
            }

            var selectedImporter = AvailableImporters.FirstOrDefault(x => x.Value == importer.ToString());

            if (selectedImporter != null)
            {
                selectedImporter.Selected = true;
            }

            return(this);
        }
        public IList <IImportJobViewModel> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            var retVal = new List <IImportJobViewModel>();

            using (var repository = _importRepository.GetRepositoryInstance())
            {
                var query = repository.ImportJobs;

                if (!string.IsNullOrEmpty(SearchFilterKeyword))
                {
                    query = query.Where(x => x.Name.Contains(SearchFilterKeyword));
                }
                else
                {
                    if (!string.IsNullOrEmpty(SearchFilterName))
                    {
                        query = query.Where(x => x.Name.Contains(SearchFilterName));
                    }
                }

                overallCount = query.Count();
                var orderedItems = !sortDescriptions.Any() ? query.OrderBy(x => x.Name) : ApplySortDescriptions(query, sortDescriptions);
                var items        = orderedItems.Skip(startIndex).Take(count).ToList();
                foreach (var item in items)
                {
                    if (AvailableImporters.Any(importer => importer.ToString() == item.EntityImporter))
                    {
                        var itemViewModel = _itemVmFactory.GetViewModelInstance(
                            new KeyValuePair <string, object>("item", item),
                            new KeyValuePair <string, object>("entityImporters", AvailableImporters),
                            new KeyValuePair <string, object>("homeMenuName", _parentViewModel.CurrentTab.IdTab)
                            );
                        retVal.Add(itemViewModel);
                    }
                    else
                    {
                        overallCount -= 1;
                    }
                }
            }
            return(retVal);
        }