/**
   * Resource to edit edit a registered hotel.
   *
   * <p>URI = http://domain/agencia/api/hotel/root/edit
   *
   * <p>Type = POST
   *
   * @param id {@link FormParam} = Hotel database id
   * @param name {@link FormParam} = Hotel name
   * @param value {@link FormParam} = Hotel daily rate
   * @param city {@link FormParam} = Hotel city
   * @param rooms {@link FormParam} = Amount of hotel rooms
   * @param isActive {@link FormParam} (flag) = Check if the hotel is active
   * @return {@link String} Response message of the AJAX request
   * @throws Exception
   */
  @POST
  @Path("/edit")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String edit(
      @FormParam("id") Integer id,
      @FormParam("name") String name,
      @FormParam("value") Float value,
      @FormParam("city") Integer city,
      @FormParam("rooms") Integer rooms,
      @FormParam("isActive") boolean isActive)
      throws Exception {

    try {
      Hotel hotel = new Hotel();
      Cidade cidade = getCity(city);

      hotel.setId(id);
      hotel.setNome(name);
      hotel.setValor(value);
      hotel.setCidade(cidade);
      hotel.setNumeroVagas(rooms);
      hotel.setActive(isActive);
      hotelService.updateHotel(hotel);

      return gson.toJson("O hotel foi editado com sucesso");
    } catch (Exception ex) {
      throw ex;
    }
  }
 /**
  * Method responsible to call {@link HotelService}, to get one City by Id
  *
  * @param {@link Integer} cityId
  * @return {@link Cidade}
  * @throws Exception
  */
 private Cidade getCity(Integer cityId) throws Exception {
   try {
     return hotelService.getCityById(cityId);
   } catch (Exception ex) {
     throw ex;
   }
 }
  /**
   * Resource to get all registered hotels.
   *
   * <p>URI = http://domain/agencia/api/hotel/root/getAll
   *
   * <p>Type = GET
   *
   * @return Object of type JSON converted to {@link String} with data of all hotels.
   * @throws Exception
   */
  @GET
  @Path("/getAll")
  @Produces({MediaType.APPLICATION_JSON})
  public String getAll() throws Exception {
    try {

      List<Hotel> hotelList = hotelService.getAllHotel();
      String hotelJSON = hotelListToJson(hotelList);
      hotelJSON = "{ \"data\"" + " : " + hotelJSON + "}";
      return hotelJSON;
    } catch (Exception ex) {
      throw ex;
    }
  }
  /**
   * Resource to edit a registered hotel.
   *
   * <p>URI = http://domain/agencia/api/hotel/root/delete
   *
   * <p>Type = POST
   *
   * @param id {@link FormParam} = Hotel database id
   * @return {@link String} Response message of the AJAX request
   * @throws Exception
   */
  @POST
  @Path("/delete")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String delete(@FormParam("id") Integer id) throws Exception {

    try {
      if (id == null || id == 0) throw new AgencyException("Não é possível deletar o hotel!");
      hotelService.deleteHotel(id);

      return gson.toJson("O hotel foi deletado com sucesso");
    } catch (Exception ex) {
      throw ex;
    }
  }