protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   session = request.getSession();
   LoginUser user = (LoginUser) session.getAttribute("user");
   if (user != null) {
     header = "templates/" + user.getHeader() + ".jsp";
     try {
       AllocateTime at = new AllocateTime();
       at.setDate(request.getParameter("Date"));
       at.setStartTime(request.getParameter("StartTime2"));
       at.setEndTime(request.getParameter("EndTime2"));
       at.setEmail(
           request.getParameter("pname")); // using pname to find correct advisor instead of email
       Visitor v = new ManageTimeSlotVisitor();
       user.accept(v, at);
       request.setAttribute("response", user.getMsg());
     } catch (Exception e) {
       System.out.printf(e.toString());
     }
   } else {
     header = "templates/header.jsp";
   }
   request.setAttribute("includeHeader", header);
   request.getRequestDispatcher("/login.jsp").forward(request, response);
 }
 public AddTimeSlot(AllocateTime at, int id) {
   date = at.getDate();
   starttime = at.getStartTime();
   endtime = at.getEndTime();
   userid = id;
   count = TimeSlotHelpers.count(at.getStartTime(), at.getEndTime());
   msg = "Unable to add time slot.";
 }
Esempio n. 3
0
 public String addTimeSlot(AllocateTime at) {
   SQLCmd cmd = new GetUserID(at.getEmail());
   cmd.execute();
   int id = (int) cmd.getResult().get(0);
   cmd = new CheckTimeSlot(at, id);
   cmd.execute();
   if ((Boolean) cmd.getResult().get(0) == true) {
     cmd = new AddTimeSlot(at, id);
     cmd.execute();
     return (String) cmd.getResult().get(0);
   } else {
     return "Unable to add time slot.";
   }
 }