private void OnSaveProject(object sender, EventArgs e) { bool successfullySaved = false; List<string> validationErrors = new List<string>(); if(String.IsNullOrWhiteSpace(this.AddProject_Name.Text)) { MessageBox.Show(String.Format("Sorry, it looks like the project name is blank. Please name the project.", this.AddProject_Name.Text)); this.AddProject_Name.BorderBrush = new SolidColorBrush(Colors.Red); return; } if(this.IsEditProject) { Project.EditProject(this.AddProject_Name.Text, this.AddProject_Description.Text, this.AddProject_RowCounterColor.Color); successfullySaved = true; } else { Project = new ProjectViewModel() { ProjectName = this.AddProject_Name.Text, ProjectDescription = this.AddProject_Description.Text, RowCounterColor = this.AddProject_RowCounterColor.Color }; try { Project.CreateProject(); successfullySaved = true; } catch (Exception ex) { MessageBox.Show(String.Format("Sorry, it looks like a project named \'{0}\' already exists. Please try a different name.", this.AddProject_Name.Text)); } } if(successfullySaved) { NavigationService.Navigate(new Uri("/MainPage.xaml?AddEditProject=1", UriKind.Relative)); } }
private void SetPageValues(string projectName) { Project = new ProjectViewModel(projectName); this.OriginalProjectName = projectName; this.AddProject_Name.Text = this.Project.ProjectName; this.AddProject_Description.Text = this.Project.ProjectDescription; this.AddProject_RowCounterColor.Color = this.Project.RowCounterColor; }