@RequestMapping(
     value = {"/updatemechanic/{id}"},
     method = {RequestMethod.POST})
 public ModelAndView updatemechanic(
     @PathVariable Long id,
     @ModelAttribute("mechanic") Mechanic mechanic,
     Model model,
     HttpSession session,
     BindingResult bindingResult,
     Authentication auth) {
   ModelAndView mav = new ModelAndView();
   mechanicValidator.validate(mechanic, bindingResult);
   if (bindingResult.hasErrors()) {
     UserPrincipal user = userService.getUserByName(auth.getName());
     mav.addObject("user", user);
     mav.addObject("mechanic", directorService.getMechanicById(id));
     mav.addObject("stos", directorService.getSto());
     mav.setViewName("director.addmechanic");
     return mav;
   }
   Mechanic mechanic1 = directorService.getMechanicById(mechanic.getUserId());
   mechanic.setLogin(mechanic.getName());
   mechanic.setRating(mechanic1.getRating());
   mechanic.setRole(UserRole.MECHANIC);
   directorService.saveOrUpdateMechanic(mechanic);
   mav.setViewName("redirect:/home");
   return mav;
 }
 @RequestMapping(
     value = {"/deletemechanic/{id}"},
     method = {RequestMethod.GET})
 public String deleteMechanic(@PathVariable Long id, Model model, HttpSession session) {
   Mechanic mechanic = directorService.getMechanicById(id);
   directorService.deleteMechanic(mechanic);
   return "redirect:/home";
 }
 @PreAuthorize("isFullyAuthenticated()")
 @RequestMapping(value = "/updatemechanic/{id}", method = RequestMethod.GET)
 public ModelAndView updatemechanic(
     @PathVariable Long id, HttpSession session, Authentication auth) {
   ModelAndView mav = new ModelAndView();
   UserPrincipal user = userService.getUserByName(auth.getName());
   mav.addObject("user", user);
   mav.addObject("mechanic", directorService.getMechanicById(id));
   mav.addObject("stos", directorService.getSto());
   mav.setViewName("director.updatemechanic");
   return mav;
 };
 @RequestMapping(
     value = {"/addsalary/{id}"},
     method = {RequestMethod.GET})
 public String addsalaryByMechanic(@PathVariable Long id, Model model, HttpSession session) {
   Mechanic mechanic = directorService.getMechanicById(id);
   Salary salary = new Salary();
   salary.setMechanic(mechanic);
   salary.setSumma(new Float(mechanic.getSalary()));
   salary.setDate(new Date());
   directorService.addSalary(salary);
   return "redirect:/home";
 }