Commit f08b4f93 authored by s7_spruge_k's avatar s7_spruge_k
Browse files

bugfix

parent 25cd7589
......@@ -189,12 +189,23 @@ public class CalendarController {
@PostMapping(value="/view-calendars", params="action=delete")
public String deleteCalendar(Model model, String calName){
Calendar c1 = calendarRepo.findByName(calName);
ArrayList<Event> allEvents = eventRepo.findAllByCalendar(c1);
for (int i = 0; i < allEvents.size(); i++) {
eventRepo.delete(allEvents.get(i));
}
calendarRepo.delete(c1);
User currUser = findCurrentUser();
ArrayList<Calendar> allUserCals = calendarRepo.findAllByUser(currUser);
currUser.setActiveCalendar(allUserCals.get(0).getName());
userRepo.save(currUser);
System.out.println(currUser);
System.out.println(allUserCals);
return "redirect:/view-calendars";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment