/// <summary> /// Edit and execute. /// </summary> private void EditDeveloperExecute() { DeveloperViewModel viewModel = this.AllDevelopers.SingleOrDefault(vm => vm.IsSelected); if (viewModel != null) { this.ShowDeveloper(viewModel); this.repository.SaveToDatabase(); } else { MessageBox.Show("Please select only one developer."); } }
/// <summary> /// Shows the item in the view. /// </summary> /// <param name="viewModel">The view model to show.</param> private void ShowDeveloper(DeveloperViewModel viewModel) { WorkspaceWindow window = new WorkspaceWindow(); window.Width = 400; window.Height = 150; window.Title = viewModel.DisplayName; viewModel.CloseAction = b => window.DialogResult = b; DeveloperView view = new DeveloperView(); view.DataContext = viewModel; window.Content = view; window.ShowDialog(); }
/// <summary> /// On developer added. /// </summary> /// <param name="sender">A Button click.</param> /// <param name="e">The click of the button.</param> private void OnDeveloperAdded(object sender, DeveloperEventArgs e) { DeveloperViewModel viewModel = new DeveloperViewModel(e.Developer, this.repository); this.AllDevelopers.Add(viewModel); }
/// <summary> /// Creates new item. /// </summary> private void CreateNewDeveloperExecute() { DeveloperViewModel viewModel = new DeveloperViewModel(new Developer(), this.repository); this.ShowDeveloper(viewModel); }