source: source/MovieZilla-master/src/main/java/com/example/demo/service/ServiceImpl/MovieProjectionImpl.java

Last change on this file was fc7ec52, checked in by darkopopovski <darkopopovski39@…>, 2 years ago

all files

  • Property mode set to 100644
File size: 2.2 KB
Line 
1package com.example.demo.service.ServiceImpl;
2
3import com.example.demo.model.Movie;
4import com.example.demo.model.MovieProjection;
5import com.example.demo.repository.MovieProjectionRepository;
6import com.example.demo.repository.MovieRepository;
7import com.example.demo.service.MovieProjectionService;
8import org.springframework.stereotype.Service;
9import org.springframework.transaction.annotation.Transactional;
10
11import java.util.List;
12import java.util.Optional;
13
14@Service
15public class MovieProjectionImpl implements MovieProjectionService {
16
17 private final MovieProjectionRepository projectionRepository;
18 private final MovieRepository movieRepository;
19
20
21 public MovieProjectionImpl(MovieProjectionRepository projectionRepository, MovieRepository movieRepository) {
22 this.projectionRepository = projectionRepository;
23 this.movieRepository = movieRepository;
24 }
25
26
27 @Override
28 public List<MovieProjection> findAll() {
29 return this.projectionRepository.findAll();
30 }
31
32 @Override
33 public Optional<MovieProjection> findById(Integer projection_id) {
34 return this.projectionRepository.findById(projection_id);
35 }
36
37 public List<MovieProjection> findAllProjections(Integer projection_id){
38 return this.projectionRepository.findAllProjections(projection_id);
39 }
40
41 @Override
42 @Transactional
43 public Optional<MovieProjection> save(
44 Integer projection_id,
45 String projection_movie_start,
46 String projection_movie_end,
47 String projection_screening_date,
48 String projection_type,
49 Float projection_price,Integer movie_id) {
50 Movie movie = this.movieRepository.findById(movie_id).get();
51 return Optional.of(this.projectionRepository.save(new MovieProjection(projection_id,projection_movie_start,projection_movie_end,
52 projection_screening_date,projection_type,projection_price,movie)));
53 }
54
55 @Override
56 public void deleteById(Integer projection_id) {
57 this.projectionRepository.deleteById(projection_id);
58 }
59
60
61 @Override
62 public List<MovieProjection> findByMovieID(Integer movie_id){
63 return this.projectionRepository.findByMovieID(movie_id);
64 }
65
66
67}
Note: See TracBrowser for help on using the repository browser.