protected EditableItemBaseVM( IOrgaSHubClientTwoWayComm twoWayComm, bool isNew) { TwoWayComm = twoWayComm; IsNew = isNew; SaveCommand = new DelegateCommand(Save, arg => IsNew || IsModified); CancelCommand = new DelegateCommand(Cancel, arg => !IsNew && IsModified); DeleteCommand = new DelegateCommand(Delete); PropertyChanged += WhenAnyPropertyIsChangedMarkAsModified; }
internal EmployeeVM( IOrgaSHubClientTwoWayComm twoWayComm, Employee dataModel, ObservableCollection <JobRoleVM> existingJobRoleVMs, bool isNew = false) : base(twoWayComm, isNew) { ExistingJobRoleVMs = existingJobRoleVMs; _dataModel = dataModel; CopyDataFromModel(); TwoWayComm.EmployeeUpdated += UpdateDataIfIsSameEntity; }
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; }