@RequestMapping("/edit-appointment")
  public String editAppointment(
      int id,
      String dateMonth,
      String dateDay,
      String dateYear,
      String dateHour,
      String dateMinute,
      String purpose,
      String doctorName,
      String patientName,
      HttpSession session)
      throws Exception {

    if (session.getAttribute("username") == null) {
      throw new Exception("not logged in");
    }
    Appointment appointment = appointments.findOne(id);
    appointment.patientName = patientName;
    appointment.doctorName = doctorName;
    appointment.purpose = purpose;
    appointment.dateMonth = dateMonth;
    appointment.dateDay = dateDay;
    appointment.dateYear = dateYear;
    appointment.dateHour = dateHour;
    appointment.dateMinute = dateMinute;
    appointments.save(appointment);

    return "redirect:/";
  }
 @RequestMapping("/delete-appointment")
 public String deleteAppointment(int id, HttpSession session) throws Exception {
   if (session.getAttribute("username") == null) {
     throw new Exception("Not logged-in");
   }
   Appointment appointment = appointments.findOne(id);
   appointments.delete(id);
   return "redirect:/";
 }
 @RequestMapping("/editPage")
 public String editPage(HttpSession session, Model model, Integer id) throws Exception {
   String username = (String) session.getAttribute("username");
   if (username == null) {
     throw new Exception("Not logged in.");
   }
   model.addAttribute("appointment", appointments.findOne(id));
   model.addAttribute("id", id);
   return "editPage";
 }