public void AddProjectAction() { var window = new AddProjectView(); var viewModel = new AddProjectViewModel { Project = new Project() }; window.DataContext = viewModel; if (window.ShowDialog() != true) { return; } Projects.Add(viewModel.Project); _dbRepositoriy.InserPoject(viewModel.Project); }
/// <summary> /// method for opening the view for adding new project /// </summary> private void AddNewProjectExecute() { try { AddProjectView addProject = new AddProjectView(manager); addProject.ShowDialog(); // updating the project list view if ((addProject.DataContext as AddProjectViewModel).IsUpdateProject == true) { ProjectList = GetAllProjects().ToList(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); } }
private void BtnNewProject_OnClick(object sender, RoutedEventArgs e) { var view = new AddProjectView(); var showDialog = view.ShowDialog(); if (showDialog != null && showDialog.Value) { var isProject = _projects.FirstOrDefault(s => s.Name == view.Project.Name); if (isProject != null) { MessageBox.Show("项目【" + view.Project.Name + "】已经存在,请重新添加项目。", "提示"); BtnNewProject_OnClick(null, null); return; } _projects.Add(view.Project); Save(); } }