use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class FavouriteMovieResource method createFavouriteMovie.
/**
* POST /favourite-movies : Create a new favouriteMovie.
*
* @param favouriteMovie the favouriteMovie to create
* @return the ResponseEntity with status 201 (Created) and with body the new favouriteMovie, or with status 400 (Bad Request) if the favouriteMovie has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/favourite-movies")
@Timed
public ResponseEntity<FavouriteMovie> createFavouriteMovie(@RequestBody FavouriteMovie favouriteMovie) throws URISyntaxException {
log.debug("REST request to save FavouriteMovie : {}", favouriteMovie);
if (favouriteMovie.getId() != null) {
throw new BadRequestAlertException("A new favouriteMovie cannot already have an ID", ENTITY_NAME, "idexists");
}
Optional<FavouriteMovie> favoriteMovieExisting = favouriteMovieRepository.findByMovieAndUserLogin(favouriteMovie.getMovie(), SecurityUtils.getCurrentUserLogin());
if (favoriteMovieExisting.isPresent()) {
favouriteMovie = favoriteMovieExisting.get();
favouriteMovie.setLiked(!favouriteMovie.isLiked());
} else {
favouriteMovie.setLiked(true);
}
favouriteMovie.setDate(ZonedDateTime.now());
favouriteMovie.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
FavouriteMovie result = favouriteMovieRepository.save(favouriteMovie);
return ResponseEntity.created(new URI("/api/favourite-movies/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class ArtistTypeResource method createArtistType.
/**
* POST /artist-types : Create a new artistType.
*
* @param artistType the artistType to create
* @return the ResponseEntity with status 201 (Created) and with body the new artistType, or with status 400 (Bad Request) if the artistType has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/artist-types")
@Timed
public ResponseEntity<ArtistType> createArtistType(@RequestBody ArtistType artistType) throws URISyntaxException {
log.debug("REST request to save ArtistType : {}", artistType);
if (artistType.getId() != null) {
throw new BadRequestAlertException("A new artistType cannot already have an ID", ENTITY_NAME, "idexists");
}
ArtistType result = artistTypeRepository.save(artistType);
return ResponseEntity.created(new URI("/api/artist-types/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class AchievementResource method createAchievement.
/**
* POST /achievements : Create a new achievement.
*
* @param achievement the achievement to create
* @return the ResponseEntity with status 201 (Created) and with body the new achievement, or with status 400 (Bad Request) if the achievement has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/achievements")
@Timed
public ResponseEntity<Achievement> createAchievement(@RequestBody Achievement achievement) throws URISyntaxException {
log.debug("REST request to save Achievement : {}", achievement);
if (achievement.getId() != null) {
throw new BadRequestAlertException("A new achievement cannot already have an ID", ENTITY_NAME, "idexists");
}
Achievement result = achievementRepository.save(achievement);
return ResponseEntity.created(new URI("/api/achievements/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class ArtistResource method createArtist.
/**
* POST /artists : Create a new artist.
*
* @param artist the artist to create
* @return the ResponseEntity with status 201 (Created) and with body the new artist, or with status 400 (Bad Request) if the artist has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/artists")
@Timed
public ResponseEntity<Artist> createArtist(@RequestBody Artist artist) throws URISyntaxException {
log.debug("REST request to save Artist : {}", artist);
if (artist.getId() != null) {
throw new BadRequestAlertException("A new artist cannot already have an ID", ENTITY_NAME, "idexists");
}
Artist result = artistRepository.save(artist);
return ResponseEntity.created(new URI("/api/artists/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.web.rest.errors.BadRequestAlertException in project FuryViewer by TheDoctor-95.
the class SeasonResource method createSeason.
/**
* POST /seasons : Create a new season.
*
* @param season the season to create
* @return the ResponseEntity with status 201 (Created) and with body the new season, or with status 400 (Bad Request) if the season has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/seasons")
@Timed
public ResponseEntity<Season> createSeason(@RequestBody Season season) throws URISyntaxException {
log.debug("REST request to save Season : {}", season);
if (season.getId() != null) {
throw new BadRequestAlertException("A new season cannot already have an ID", ENTITY_NAME, "idexists");
}
Season result = seasonRepository.save(season);
return ResponseEntity.created(new URI("/api/seasons/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations