Ejemplo n.º 1
0
        public void AddTable(Object parentVm, Object entityTableInfoObj)
        {
            if (entityTableInfoObj != null && entityTableInfoObj is EntityTableInfo)
            {
                EntityTableInfo entityTableInfo = (entityTableInfoObj as EntityTableInfo);

                DbSet<InfCodeDashboard> datasCodeDashboard = _dataService.GetDbSet<InfCodeDashboard>();
                DbSet<InfDashboard> datasDashboard = _dataService.GetDbSet<InfDashboard>();
                InfDashboard dashboardTable = new InfDashboard();
                dashboardTable.Code = entityTableInfo.SchemaName+"."+entityTableInfo.TableName;
                dashboardTable.Libelle = entityTableInfo.DisplayName;
                if (parentVm != null && parentVm is DashboardFolderViewModel)
                {
                    DashboardFolderViewModel folder = parentVm as DashboardFolderViewModel;
                    dashboardTable.IdParent = folder.Model.Id;
                }
                else
                { dashboardTable.IdParent = -1; }

                dashboardTable.InfCodeDashboard = (from c in datasCodeDashboard where c.Code.Equals("TABLE") select c).FirstOrDefault();
                dashboardTable.Ordre = this.Items.Count + 1;
                datasDashboard.Add(dashboardTable);
                IEnumerable<DbEntityValidationResult> results = _dataService.DataContext.GetValidationErrors();
                _dataService.DataContext.SaveChanges();

                DashboardTableViewModel tableVm = new DashboardTableViewModel();
                tableVm.DisplayName = entityTableInfo.DisplayName;
                tableVm.Model = dashboardTable;
                if (parentVm != null && parentVm is DashboardFolderViewModel)
                {
                    DashboardFolderViewModel folder = parentVm as DashboardFolderViewModel;
                    folder.Items.Add(tableVm);
                    folder.IsExpanded = true;
                    tableVm.IsSelected = true;
                }
                else
                {
                    this.Items.Add(tableVm);
                    tableVm.IsSelected = true;
                }

                this.FillOrder();
            }
        }
Ejemplo n.º 2
0
 private void CollectItemToRemove(InfDashboard infDashboard, List<InfDashboard> itemsToRemove)
 {
     IQueryable<InfDashboard> query = _dataService.GetDbSet<InfDashboard>().AsQueryable<InfDashboard>();
     List<InfDashboard> childItems = (from i in query where i.IdParent == infDashboard.Id select i).ToList();
     foreach (InfDashboard childItem in childItems)
     {
         itemsToRemove.Add(childItem);
         this.CollectItemToRemove(childItem, itemsToRemove);
     }
 }
Ejemplo n.º 3
0
        public void AddFolder()
        {
            DbSet<InfCodeDashboard> datasCodeDashboard = _dataService.GetDbSet<InfCodeDashboard>();
            DbSet<InfDashboard> datasDashboard = _dataService.GetDbSet<InfDashboard>();
            DashboardDialogFolderViewModel vm = new DashboardDialogFolderViewModel();
            DashboardDialogFolderView v = new DashboardDialogFolderView();
            v.DataContext = vm;
            v.Owner = System.Windows.Application.Current.MainWindow;
            Nullable<Boolean> result = v.ShowDialog();
            if (result.HasValue && result.Value == true)
            {
                InfDashboard dashboardFolder = new InfDashboard();
                dashboardFolder.Code = vm.FolderName;
                dashboardFolder.Libelle = vm.FolderName;
                dashboardFolder.IdParent = -1;
                dashboardFolder.InfCodeDashboard = (from c in datasCodeDashboard where c.Code.Equals("FOLDER") select c).FirstOrDefault();
                dashboardFolder.Ordre = this.Items.Count +1;
                datasDashboard.Add(dashboardFolder);
                IEnumerable<DbEntityValidationResult> results =  _dataService.DataContext.GetValidationErrors();
                _dataService.DataContext.SaveChanges();

                DashboardFolderViewModel folder = new DashboardFolderViewModel();
                folder.DisplayName = vm.FolderName;
                folder.Model = dashboardFolder;
                this.Items.Add(folder);
                this.FillOrder();
            }
        }