use of com.furyviewer.domain.FavouriteSeries in project FuryViewer by TheDoctor-95.
the class FavouriteSeriesResource method createFavouriteSeries.
/**
* POST /favourite-series : Create a new favouriteSeries.
*
* @param favouriteSeries the favouriteSeries to create
* @return the ResponseEntity with status 201 (Created) and with body the new favouriteSeries, or with status 400 (Bad Request) if the favouriteSeries has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/favourite-series")
@Timed
public ResponseEntity<FavouriteSeries> createFavouriteSeries(@RequestBody FavouriteSeries favouriteSeries) throws URISyntaxException {
log.debug("REST request to save FavouriteSeries : {}", favouriteSeries);
if (favouriteSeries.getId() != null) {
throw new BadRequestAlertException("A new favouriteSeries cannot already have an ID", ENTITY_NAME, "idexists");
}
Optional<FavouriteSeries> existingFavouriteSeries = favouriteSeriesRepository.findBySeriesAndUserLogin(favouriteSeries.getSeries(), SecurityUtils.getCurrentUserLogin());
if (existingFavouriteSeries.isPresent()) {
throw new BadRequestAlertException("El serie ya esta aƱadida a favoritos", ENTITY_NAME, "favoriteExist");
}
favouriteSeries.setDate(ZonedDateTime.now());
favouriteSeries.setUser(userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get());
FavouriteSeries result = favouriteSeriesRepository.save(favouriteSeries);
return ResponseEntity.created(new URI("/api/favourite-series/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.furyviewer.domain.FavouriteSeries in project FuryViewer by TheDoctor-95.
the class FavouriteSeriesResource method favouriteSeries.
@PostMapping("/favourite-series/id/{idSeries}/liked")
@Timed
public ResponseEntity<FavouriteSeries> favouriteSeries(@PathVariable Long idSeries) throws URISyntaxException {
log.debug("REST request to save FavouriteSeries : {}", idSeries);
Series s = seriesRepository.findOne(idSeries);
FavouriteSeries fS = new FavouriteSeries();
fS.setSeries(s);
fS.setLiked(true);
return createFavouriteSeries(fS);
}
Aggregations