Skip to content

Commit

Permalink
Got rid of print statements and refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanland committed Oct 3, 2018
1 parent 3b12e77 commit 25d584d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions server/src/main/java/capstone/controller/ProjectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,30 @@ public String assignmentExists() {
public @ResponseBody String assignProjectsToStudents(@RequestBody List<Project> projectMatches) {
List<Project> updatedProjects = new ArrayList<Project>();

for(Stakeholder s : userService.getStakeholders()) {
System.out.println(s.getFirstName() + " " + s.getUserId());
}
for (Project proj : projectMatches) {
if (proj.getProjectId() > 0) {
Project project = projectService.findByProjectId(proj.getProjectId());
updatedProjects.add(project);

// Determine stakeholder for project
Stakeholder stakeholder = userService.findByStakeholderId((long) project.getStakeholderId());
System.out.print("ID: " + project.getStakeholderId() + "\nstakeholder: ");
String stakeholderEmail = "";
if(stakeholder == null) {
stakeholderEmail = "Please contact the professor for the email of your stakeholder";
} else {
stakeholderEmail = stakeholder.getEmail();
System.out.print(stakeholder.getFirstName());
}
System.out.println(" ");

// Construct email body
String messageBody = project.getProjectName() + "\n\nProject Background: " + project.getBackground() + "\n\nProject Description: " + project.getDescription()
+ "\n\nStakeholder Email: " + stakeholderEmail + "\n\nTo find out who is on your team please login to the class website.";


// Email each student in the group the information
for (Student student : proj.getMembers()) {
// Set the given project for each student
Student saveStudent = userService.findByUserId(student.getUserId());
saveStudent.setProject(project);

emailService.sendEmail("CSCI 401 Project Assignment", messageBody, saveStudent.getEmail());
userService.saveUser(saveStudent);
}
Expand Down

0 comments on commit 25d584d

Please sign in to comment.