public CostumerViewModel() { this._projectCatalog = ProjectCatalog.Instance; this._costumerCatalog = CostumerCatalog.Instance; this.OnPropertyChanged(nameof(this.CostumerList)); this.DeleteCustomerCommand = new RelayCommand <Costumer>( () => { this._costumerCatalog.Remove( this ._selectedCostumer); this._selectedCostumer = null; this.OnPropertyChanged( nameof( this.CostumerList )); }, costumer => this.ProjectsForCostumer.Count == 0); this.UpdateCustomerCommand = new RelayCommand <Costumer>( () => { int id = this._selectedCostumer.CostumerId; this._costumerCatalog.Update( this ._selectedCostumer); this.OnPropertyChanged( nameof( this.CostumerList )); this.SelectedCostumer = this.CostumerList.Find( costumer => costumer .CostumerId == id); }, costumer => this.Edit); this.Edit = false; this.RefreshCommand = new RelayCommand <bool>( () => { this._projectCatalog.Load(); this._costumerCatalog.Load(); this.OnPropertyChanged(nameof(this.CostumerList)); this.OnPropertyChanged(nameof(this.SelectedCostumer)); this.OnPropertyChanged( nameof(this.ProjectsForCostumer )); }); }
public EmployeeViewModel() { this._projectCatalog = ProjectCatalog.Instance; this._employeeCatalog = EmployeeCatalog.Instance; this._projectsForEmployee = ProjectForEmployeesCatalog.Instance; this._canEdit = false; this.DeleteCommand = new RelayCommand <Employee>( () => { this._employeeCatalog.Remove( this ._selectedEmployee); this._selectedEmployee = null; this.OnPropertyChanged(nameof(this.EmployeeList)); }, employee => this._employeeCatalog.EmployeeList.Contains( this .SelectedEmployee)); this.UpdateCommand = new RelayCommand <Employee>( () => { int id = this._selectedEmployee.EmployeeId; this._employeeCatalog.Update( this ._selectedEmployee); this.OnPropertyChanged(nameof(this.EmployeeList)); this.SelectedEmployee = this.EmployeeList.Find( employee => employee.EmployeeId == id); }, employee => this.Edit); this.RefreshCommand = new RelayCommand <bool>( () => { this._projectCatalog.Load(); this._employeeCatalog.Load(); this._selectedEmployee = null; this.OnPropertyChanged(nameof(this.EmployeeList)); }); }
/// <summary> /// Occurs when user press enter in inserion row. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridCollectionViewSource_CommittingNewItem(object sender, DataGridCommittingNewItemEventArgs e) { try { WorkingStatusHelper.SetBusy((string)App.Current.FindResource("LoadingProjectStatus")); ProjectCatalog projectBrowser = App.Current.ProjectCatalog; List <ProjectDataWrapper> source = e.CollectionView.SourceCollection as List <ProjectDataWrapper>; ProjectDataWrapper projectDataTemplate = e.Item as ProjectDataWrapper; App.Current.NewProject(projectDataTemplate.Name, projectBrowser.FolderPath, projectDataTemplate.Description); source.Add(projectDataTemplate); // update layout UpdateView(); e.Index = source.Count - 1; e.NewCount = source.Count; e.Handled = true; } catch (ApplicationException ex) { Logger.Info(ex); App.Current.Messenger.AddWarning(ex.Message); } catch (Exception ex) { Logger.Info(ex); App.Current.Messenger.AddWarning(ex.Message); } finally { WorkingStatusHelper.SetReleased(); App.Current.MainWindow.StatusBar.SetStatus(this, null); } }
public ProjectViewModel() { this._projectCatalog = ProjectCatalog.Instance; this._employeeCatalog = EmployeeCatalog.Instance; this._costumerCatalog = CostumerCatalog.Instance; this._projectForEmployeesCatalog = ProjectForEmployeesCatalog.Instance; this._addEmployee = new Employee(); this._projectForEmployee = new ProjectsForEmployee(); this.DeleteCommand = new RelayCommand <Project>( () => { this._projectCatalog.Remove(this.SelectedProject); this._selectedProject = null; this.OnPropertyChanged(nameof(this.ProjectList)); }, project => this.SelectedProject != null); this.UpdateCommand = new RelayCommand <Project>( () => { int id = this._selectedProject.ProjectId; this._projectCatalog.Update(this._selectedProject); this.OnPropertyChanged(nameof(this.ProjectList)); this.SelectedProject = this.ProjectList.Find( project => project.ProjectId == id); foreach (ProjectsForEmployee projectsForEmployee in this.EmployeesForProject) { this._projectForEmployeesCatalog.Update( projectsForEmployee); this._employeeCatalog.Load(); } }, project => this.Edit); this.AddEmployeeCommand = new RelayCommand <Employee>( () => { this._projectForEmployee.ProjectId = this._selectedProject.ProjectId; this._projectForEmployee.EmployeeId = this._addEmployee.EmployeeId; this._projectForEmployee.IsLeader = false; this._projectForEmployeesCatalog.Add( this ._projectForEmployee); this._employeeCatalog.Load(); this._addEmployee = new Employee(); this.OnPropertyChanged( nameof( this.AddEmployeeName )); this.OnPropertyChanged( nameof( this .EmployeesForProject )); this.AddEmployeeCommand .RaiseCanExecuteChanged(); }, addEmployee => { if (this._addEmployee.Name == null || this.EmployeesForProject.Exists( employee => employee .EmployeeId == this ._addEmployee .EmployeeId) ) { return(false); } if (this._employeeCatalog.EmployeeList.Exists( employee => employee .Name == this ._addEmployee .Name) && this.Edit) { return(true); } return(false); }); this.DeleteEmployeeCommand = new RelayCommand <Employee>( () => { this._projectForEmployeesCatalog.Remove( this ._selectedEmployee .ProjectsForEmployees .First( employee => employee .ProjectId == this ._selectedProject .ProjectId)); this._employeeCatalog.Load(); this._selectedEmployee = null; this.OnPropertyChanged( nameof( this .EmployeesForProject )); this.DeleteEmployeeCommand .RaiseCanExecuteChanged(); }, employee => this._selectedEmployee != null && this._selectedProject != null && this.Edit); this._canEdit = false; this.RefreshCommand = new RelayCommand <bool>( () => { this._projectCatalog.Load(); this._employeeCatalog.Load(); this._costumerCatalog.Load(); this.OnPropertyChanged(nameof(this.ProjectList)); this.OnPropertyChanged(nameof(this.SelectedProject)); this.OnPropertyChanged( nameof(this.EmployeesForProject )); }); }
public ProjectFactory() { this.NewProject = new Project(); this._projectCatalog = ProjectCatalog.Instance; }