@ApiOperation(
      value = "UnVote for LunchMenu.",
      notes = "Returns NO_CONTENT if unVoting was successful.")
  @ApiResponses(
      value = {
        @ApiResponse(code = 401, message = "Only authenticated access allowed."),
        @ApiResponse(code = 403, message = "Only user of ADMIN role can have access to it."),
        @ApiResponse(code = 404, message = "LunchMenu with such Id not found."),
      })
  @RequestMapping(value = "/{id}/unvote", method = RequestMethod.POST)
  public Long unVote(
      @ApiParam(value = "ID of LunchMenu from DB", required = true) @PathVariable Long id,
      @ApiParam(value = "authentication ", hidden = true) Authentication authentication) {
    SpringUser springUser = (SpringUser) authentication.getPrincipal();
    LOGGER.debug("Voting on LunchMenu (id={}) by {}", id, springUser.getUsername());
    Optional<LunchMenu> menuSearch = lunchMenusService.getLunchMenuById(id, springUser.getRole());
    menuSearch.orElseThrow(
        () -> new ExceptionLunchMenuNotFound(String.format("LunchMenu=%s not found.", id)));
    Optional<User> userSearch = usersService.getUserById(springUser.getId());
    userSearch.orElseThrow(
        () -> new UsersController.ExceptionUserNotFound(String.format("User=%s not found.", id)));

    Long result = voteService.unVote(menuSearch.get(), userSearch.get());
    return result;
  }
  @PreAuthorize("hasAuthority('ADMIN')")
  @RequestMapping(value = "", method = RequestMethod.POST)
  @ApiOperation(
      value = "Create new LunchMenu.",
      notes = "Returns a new LunchMenu and persisted it to DB.",
      response = LunchMenu.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 401, message = "Only authenticated access allowed."),
        @ApiResponse(code = 403, message = "Only user of ADMIN role can have access to it."),
        @ApiResponse(
            code = 400,
            message =
                "Reasons:\n1:Properties 'theDay' and 'theRestaurantId' must have value.\n"
                    + "2:lunchMenuAsDto.idLunchMenu set to other value than 0.\n"
                    + "3:Other combination of lunchMenuAsDto.theDay and lunchMenuAsDto.theRestaurantId already exists.")
      })
  public LunchMenu createLunchMenu(
      @ApiParam(value = "new properties of LunchMenu", required = true) @Valid @RequestBody
          LunchMenuDto lunchMenuAsDto) {
    LOGGER.debug("Create new LunchMenu {}", lunchMenuAsDto);
    checkIdLunchMenuEmpty(lunchMenuAsDto);

    LunchMenu restaurant = lunchMenusService.createLunchMenu(lunchMenuAsDto);
    return restaurant;
  }
  @RequestMapping(value = "", method = RequestMethod.GET)
  @ApiOperation(
      value = "Get All LunchMenus.",
      notes = "Returns list of all existed LunchMenus by page.")
  @ApiResponses(
      value = {
        @ApiResponse(code = 401, message = "Only authenticated access allowed."),
      })
  public Page<LunchMenu> getAllLunchMenus(
      @RequestParam(value = "page", required = true, defaultValue = DEFAULT_PAGE_NUM)
          @ApiParam(value = "Page number of LunchMenus list", required = false)
          Integer page,
      @ApiParam(
              value = "Size of Page of LunchMenus list. ",
              allowableValues = "range[1,1000]",
              required = false)
          @RequestParam(value = "size", required = true, defaultValue = DEFAULT_PAGE_SIZE)
          Integer size,
      @ApiParam(value = "", hidden = true) Authentication authentication) {
    SpringUser springUser = (SpringUser) authentication.getPrincipal();
    LOGGER.debug(
        "Get all LunchMenu on page {} with size {} by {}", page, size, springUser.getUsername());

    size = Math.min(1000, size);
    return lunchMenusService.getAllLunchMenus(page, size, springUser.getRole());
  }
 @PreAuthorize("hasAuthority('ADMIN')")
 @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
 @ResponseStatus(HttpStatus.NO_CONTENT)
 @ApiOperation(
     value = "Update new LunchMenu.",
     notes = "Returns NO_CONTENT if update was successful.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 401, message = "Only authenticated access allowed."),
       @ApiResponse(code = 403, message = "Only user of ADMIN role can have access to it."),
       @ApiResponse(code = 404, message = "LunchMenu with such Id not found."),
       @ApiResponse(
           code = 400,
           message =
               "Reasons:\n1:Properties 'theDay' and 'theRestaurantId' must have value.\n"
                   + "2:value of ID different between Id in URL and lunchMenuDto .\n"
                   + "3:Other combination of lunchMenuAsDto.theDay and lunchMenuAsDto.theRestaurantId already exists.")
     })
 public void updateLunchMenu(
     @ApiParam(value = "ID of LunchMenu from DB", required = true) @PathVariable Long id,
     @ApiParam(value = "new properties of LunchMenu", required = true) @Valid @RequestBody
         LunchMenuDto lunchMenuDto) {
   LOGGER.debug("Update LunchMenu {} ", lunchMenuDto);
   checkUrlAndBodyForId(id, lunchMenuDto);
   try {
     lunchMenusService.updateLunchMenu(id, lunchMenuDto);
   } catch (NoSuchElementException exception) {
     throw new ExceptionLunchMenuNotFound(exception.getMessage());
   }
 }
 @ApiOperation(value = "Cancel LunchMenu.", notes = "Returns NO_CONTENT if cancel was successful.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 401, message = "Only authenticated access allowed."),
       @ApiResponse(code = 403, message = "Only user of ADMIN role can have access to it."),
       @ApiResponse(code = 404, message = "LunchMenu with such Id not found."),
     })
 @PreAuthorize("hasAuthority('ADMIN')")
 @RequestMapping(value = "/{id}/cancel", method = RequestMethod.PUT)
 @ResponseStatus(HttpStatus.NO_CONTENT)
 public void cancelLunchMenu(
     @ApiParam(value = "ID of LunchMenu from DB", required = true) @PathVariable Long id) {
   LOGGER.debug("Cancel LunchMenu {} ", id);
   try {
     lunchMenusService.cancelLunchMenu(id);
   } catch (NoSuchElementException exception) {
     throw new ExceptionLunchMenuNotFound(exception.getMessage());
   }
 }
 @ApiOperation(
     value = "Find LunchMenu by ID.",
     notes = "Returns a LunchMenu if found it.",
     response = Restaurant.class)
 @ApiResponses(
     value = {
       @ApiResponse(code = 401, message = "Only authenticated access allowed."),
       @ApiResponse(code = 404, message = "LunchMenu with such Id not found.")
     })
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 public LunchMenu getLunchMenu(
     @ApiParam(value = "ID of LunchMenu from DB", required = true) @PathVariable Long id,
     @ApiParam(value = "authentication", hidden = true) Authentication authentication)
     throws ExceptionLunchMenuNotFound {
   SpringUser springUser = (SpringUser) authentication.getPrincipal();
   LOGGER.debug("Get LunchMenu (id={}) by {}", id, springUser.getUsername());
   return lunchMenusService
       .getLunchMenuById(id, springUser.getRole())
       .orElseThrow(
           () -> new ExceptionLunchMenuNotFound(String.format("LunchMenu=%s not found.", id)));
 }