public bool CreateProject(ProjectInfo prInf) { ProjectDAO dao = new ProjectDAO(); return(dao.CreateProject(prInf)); }
private void CreateProject_Click(object sender, RoutedEventArgs e) { string name = this.name.Text; string description = this.description.Text; DateTime deadline = this.deadline.SelectedDate.ToString() == "" ? DateTime.MinValue : this.deadline.SelectedDate.Value; try { if (InputsReq()) { if (!name.Equals("")) { Project project = new Project(); project.Name = name; project.Description = description; project.DueDate = deadline; project.ProjectOwnerID = user.Id; ProjectDAO projectDAO = new ProjectDAO(); int projectID = projectDAO.CreateProject(project); foreach (int userID in userList) { projectDAO.AddUserToProject(projectID, userID); } this.Close(); if (inviteUserToProject != null) { inviteUserToProject.Close(); } utilities.GetNotifier().ShowSuccess("Projektet blev oprettet!"); home.NewProjectElement(projectID, name); if (mainController.Project == null) { mainController.Project = projectDAO.Read(projectID); mainController.ChangeProject(); } } } else { if (!NameFieldReq(name)) { utilities.GetNotifier().ShowError("Indtast venligst et projektnavn"); } else if (!DescripFieldReq(description)) { utilities.GetNotifier().ShowError("Indtast venligst en beskrivelse"); } else if (!DateFieldReq(deadline)) { utilities.GetNotifier().ShowError("Vælg en gyldig deadline"); } } } catch (Exception exception) { utilities.GetNotifier().ShowError(utilities.HandleException(exception)); } }