public ViewModelStructuredBase(PermissionItemName screen) { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(screen.ToString()); InitializeCommands(); } }
public GenericViewModelCollection(string tablEname, PermissionItemName userJobsForm) { if (DesignerProperties.IsInDesignTool) { return; } TablEname = tablEname; Client = new _Proxy.CRUD_ManagerServiceClient(); GetItemPermissions(userJobsForm.ToString()); Client.GetGenericCompleted += (s, ev) => { Loading = false; GenericMapper.InjectFromObCollection(MainRowList, ev.Result); //FullCount = ev.fullCount; if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0)) { SelectedMainRow = MainRowList.FirstOrDefault(); } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } if (Export) { Export = false; ExportGrid.ExportExcel(userJobsForm.ToString()); } }; MainRowList = new SortableCollectionView <GenericViewModel>(); Client.GenericUpdateOrInsertCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } Loading = false; MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result); }; Client.DeleteGenericCompleted += (s, ev) => { if (ev.Error != null) { MessageBox.Show(ev.Error.Message); } Loading = false; var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } if (!MainRowList.Any()) { AddNewMainRow(false); } }; GetMaindata(); }