Ejemplo n.º 1
0
 @Override
 public ModelAndView postEditView(
     @ModelAttribute("Model") Player model, HttpServletRequest request, BindingResult result) {
   validator.validate(model, result);
   if (result.hasErrors()) {
     return getEditView(model);
   }
   // make sure not to overwrite passwordHash, verfied etc.
   Player player;
   if (model.getId() != null) {
     player = playerDAO.findById(model.getId());
   } else {
     Player existingPlayer = playerDAO.findByEmail(model.getEmail());
     if (existingPlayer != null) {
       result.addError(new ObjectError("email", msg.get("EmailAlreadyRegistered")));
       return getEditView(model);
     }
     player = new Player();
   }
   player.setEmail(model.getEmail());
   player.setFirstName(model.getFirstName());
   player.setLastName(model.getLastName());
   player.setPhone(model.getPhone());
   player.setGender(model.getGender());
   player.setInitialRanking(model.getInitialRanking());
   playerDAO.saveOrUpdate(player);
   return redirectToIndex(request);
 }
Ejemplo n.º 2
0
 @RequestMapping("mail")
 public ModelAndView mailAll(HttpServletRequest request) {
   List<Player> allPlayers = playerDAO.findPlayersRegisteredForEmails();
   List<String> emails = new ArrayList<>();
   for (Player player : allPlayers) {
     emails.add(player.getEmail());
   }
   ModelAndView mav = new ModelAndView("admin/players/mail");
   mav.addObject("bcc", StringUtils.join(emails, ","));
   mav.addObject(
       "body",
       msg.get(
           "MailAllPlayersBody",
           new Object[] {RequestUtil.getBaseURL(request) + "/account/profile"}));
   return mav;
 }