Example #1
0
        public FolderSettingsViewModel()
        {
            Reload(Domain.SubModuleType.Analytics);
            SubModuleKeys = Enum.GetValues(typeof(Domain.SubModuleType)).Cast <Domain.SubModuleType>().ToList();

            var selectedObservable = this.WhenAnyObservable(x => x.SelectedFolderList.ItemChanged)
                                     .Where(x => x.PropertyName == "IsSelected")
                                     //.Select(_ => FilterItems.Any(x => x.IsSelected));

                                     .Subscribe(x =>
            {
                switch (SelectedModuleIndex)     //TODO:
                {
                case 0:
                    if (x.Sender.IsSelected)
                    {
                        AnalyticFolderSet.Add(x.Sender.Name);
                        //MasterFolderSet.SelectedAnalyticFolders.Add(x.Sender.Name);
                    }
                    else
                    {
                        AnalyticFolderSet.Remove(x.Sender.Name);
                        //MasterFolderSet.SelectedAnalyticFolders.Remove(x.Sender.Name);
                    }
                    break;

                case 1:
                    if (x.Sender.IsSelected)
                    {
                        EverydayFolderSet.Add(x.Sender.Name);
                    }
                    else
                    {
                        EverydayFolderSet.Remove(x.Sender.Name);
                    }
                    break;

                case 2:
                    if (x.Sender.IsSelected)
                    {
                        PromoFolderSet.Add(x.Sender.Name);
                    }
                    else
                    {
                        PromoFolderSet.Remove(x.Sender.Name);
                    }
                    break;

                case 3:
                    if (x.Sender.IsSelected)
                    {
                        KitFolderSet.Add(x.Sender.Name);
                    }
                    else
                    {
                        KitFolderSet.Remove(x.Sender.Name);
                    }
                    break;
                }

                //Publisher.Publish<FoldersSelectedVM>(x.Sender);

                //Console.WriteLine("test");
            });

            var selectedO = this.WhenAnyValue(x => x.SelectedFolderList.ItemChanged);

            //.Where(x => x.PropertyName == "IsSelected");
            //.Select(_ => FilterItems.Any(x => x.IsSelected));

            selectedO.Subscribe(x =>
            {
                Console.WriteLine("test");
            });


            SelectedFolderList.ItemChanged.Subscribe(x =>
            {
                Console.WriteLine("t");
            });


            //var master =((HomeSearchViewModel)MainViewModel.SubModuleCache[Domain.SubModuleType.Search]).FolderSet;


            //SelectedAnalyticFolders = master.SelectedAnalyticFolders.Select(x => new FoldersSelectedVM { Name = x, IsSelected = true }).ToList();
            //MasterAnalyticFoldersVM = master.MasterAnalyticFolderList.Select( x=> new FoldersSelectedVM {Name = x, IsSelected = false}).ToList();

            //var unique = SelectedAnalyticFolders
            //    .Concat(MasterAnalyticFoldersVM)
            //    .GroupBy(item => item.Name)
            //    .Select(group => group.First()).ToList();

            //MasterEveryDayFolders = master.MasterEverydayFolderList;
            //MasterKitFolders = master.MasterKitFolderList;
            //MasterPromotionFolders = master.MasterPromotionFolderList;

            Publisher.GetEvent <Views.FolderModuleSelectedEvent>()
            .Subscribe(evt =>
            {
                switch (evt.SelectedIndex)
                {
                case 0:

                    Reload(Domain.SubModuleType.Analytics);
                    break;

                case 1:
                    Reload(Domain.SubModuleType.Everyday);
                    break;

                case 2:
                    Reload(Domain.SubModuleType.Promotions);
                    break;

                case 3:
                    Reload(Domain.SubModuleType.Kits);
                    break;

                default:
                    break;
                }
            });
        }
Example #2
0
        public void Reload(Domain.SubModuleType submodule)
        {
            try
            {
                //save to in memory if folderList != null until flushed to db when user clicks save link
                var master = ((SearchViewModel)MainViewModel.SubModuleCache[Domain.SubModuleType.Search]);

                //MasterFolderSet = ((HomeSearchViewModel)MainViewModel.SubModuleCache[Domain.SubModuleType.Search]).FolderSet;
                AnalyticFolderSet       = master.FolderSet.SelectedAnalyticFolders.ToList();
                MasterAnalyticFolderSet = master.FolderSet.MasterAnalyticFolderList.ToList();

                EverydayFolderSet       = master.FolderSet.SelectedEverydayFolders.ToList();
                MasterEverydayFolderSet = master.FolderSet.MasterEverydayFolderList.ToList();

                PromoFolderSet       = master.FolderSet.SelectedPromotionFolders.ToList();
                MasterPromoFolderSet = master.FolderSet.MasterPromotionFolderList.ToList();

                KitFolderSet       = master.FolderSet.SelectedKitFolders.ToList();
                MasterKitFolderSet = master.FolderSet.MasterKitFolderList.ToList();

                List <FoldersSelectedVM> selectedVMs = null; List <FoldersSelectedVM> masterVMs = null;
                switch (submodule)
                {
                case Domain.SubModuleType.Analytics:

                    selectedVMs = AnalyticFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = true
                    }).ToList();
                    masterVMs = MasterAnalyticFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = false
                    }).ToList();
                    //masterVMs = MasterFolderSet.MasterAnalyticFolderList.Select(x => new FoldersSelectedVM { Name = x, IsSelected = false }).ToList();
                    Title = "Folders";
                    SelectedModuleIndex = 0;
                    break;

                case Domain.SubModuleType.Everyday:
                    selectedVMs = EverydayFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = true
                    }).ToList();
                    masterVMs = MasterEverydayFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = false
                    }).ToList();
                    Title = "Folders";
                    SelectedModuleIndex = 1;
                    break;

                case Domain.SubModuleType.Promotions:
                    selectedVMs = PromoFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = true
                    }).ToList();
                    masterVMs = MasterPromoFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = false
                    }).ToList();
                    Title = "Folders";
                    SelectedModuleIndex = 2; break;

                case Domain.SubModuleType.Kits:
                    selectedVMs = KitFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = true
                    }).ToList();
                    masterVMs = MasterKitFolderSet.Select(x => new FoldersSelectedVM {
                        Name = x, IsSelected = false
                    }).ToList();
                    Title = "Folders";
                    SelectedModuleIndex = 3;
                    break;

                default:
                    break;
                }

                var folderList = selectedVMs
                                 .Concat(masterVMs)
                                 .GroupBy(item => item.Name)
                                 .Select(group => group.First()).ToList();

                SelectedFolderList.Clear();
                foreach (var item in folderList)
                {
                    SelectedFolderList.Add(item);
                }

                //SelectedFolderList.AddRange(folderList);
            }
            catch (Exception)
            {
                //throw;
            }
        }