internal MainWindowVM(ImportExportImp importExportImp) { var serverHubUrl = DemoUrlConstants.LocalHostUrl + DemoUrlConstants.OrgaSHubEndpoint; _orgaSHubClientTwoWayComm = new OrgaSHubClientTwoWayComm(serverHubUrl); OrganizationalStructureVM = new OrganizationalStructureVM(_orgaSHubClientTwoWayComm, importExportImp); ChangesLiveUploadVM = new ChangesLiveUploadVM(OrganizationalStructureVM); ConnectCommand = new DelegateCommand(Connect, arg => !IsConnected); ChangesLiveUploadVM.ShouldDoLiveUploads = true; }
public MainWindow() { InitializeComponent(); var importExportImp = new ImportExportImp(this); _mainWindowVM = new MainWindowVM(importExportImp); DataContext = _mainWindowVM; _mainWindowVM.ShowMessageBox += ShowMessageBox; Loaded += AutomaticConnect; }
internal OrganizationalStructureVM( IOrgaSHubClientTwoWayComm twoWayComm, ImportExportImp importExportImp) { _importExportImp = importExportImp; _organisationDataModel = new Organisation() { JobRoles = new List <JobRole>(), Employees = new List <Employee>() }; SimpleHierarchyVM = new SimpleHierarchyVM(this); ExportCommand = new DelegateCommand( arg => { foreach (var item in JobRoles) { item.SaveCommand.Execute(null); } foreach (var item in Employees) { item.SaveCommand.Execute(null); } _importExportImp.Export(_organisationDataModel); }); ImportCommand = new DelegateCommand( arg => { var organisation = _importExportImp.Import(); if (organisation != null) { _twoWayComm.ServerHubProxy.ImportOrganisation(organisation); } }); AddJobRoleCommand = new DelegateCommand(CreateNewJobRole); AddEmployeeCommand = new DelegateCommand(CreateNewEmployee); _twoWayComm = twoWayComm; _twoWayComm.JobRoleCreated += AddNewJobRoleFromServer; _twoWayComm.EmployeeCreated += AddNewEmployeeFromServer; _twoWayComm.JobRoleDeleted += RemoveLocalJob; _twoWayComm.EmployeeDeleted += RemoveLocalEmployee; _twoWayComm.LoadOrganisation += OnLoadOrganisation; }