class FavoritePlaceServiceImpl implements FavoritePlaceService {

    @Override
    public FavoritePlaceDto save(FavoritePlaceDto favoritePlaceDto, String userEmail) {
        log.info(LogMessage.IN_SAVE, favoritePlaceDto);
        FavoritePlace favoritePlace = modelMapper.map(favoritePlaceDto, FavoritePlace.class);
        if (!placeService.existsById(favoritePlace.getPlace().getId())) {
            throw new WrongIdException(ErrorMessage.PLACE_NOT_FOUND_BY_ID);
        }
        if (repo.findByPlaceIdAndUserEmail(favoritePlaceDto.getPlaceId(), userEmail) != null) {
            throw new WrongIdException(String.format(
                ErrorMessage.FAVORITE_PLACE_ALREADY_EXISTS, favoritePlaceDto.getPlaceId(), userEmail));
        }
        favoritePlace.setUser(User.builder().email(userEmail).id(userService.findIdByEmail(userEmail)).build());
        return modelMapper.map(repo.save(favoritePlace), FavoritePlaceDto.class);
    }

}