source: src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java@ 00fa72f

Last change on this file since 00fa72f was 5867520, checked in by DenicaKj <dkorvezir@…>, 22 months ago

Projections

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package com.example.moviezone.service.Impl;
2
3import com.example.moviezone.model.Film;
4import com.example.moviezone.model.Projection;
5import com.example.moviezone.repository.FilmRepository;
6import com.example.moviezone.repository.ProjectionRepository;
7import com.example.moviezone.service.ProjectionService;
8import org.springframework.stereotype.Service;
9
10import java.time.LocalDate;
11import java.util.List;
12
13@Service
14public class ProjectionServiceImpl implements ProjectionService {
15 private final ProjectionRepository projectionRepository;
16 private final FilmRepository filmRepository;
17 public ProjectionServiceImpl(ProjectionRepository projectionRepository, FilmRepository filmRepository) {
18 this.projectionRepository = projectionRepository;
19 this.filmRepository = filmRepository;
20 }
21
22 @Override
23 public List<Projection> findAllProjections() {
24 return projectionRepository.findAll();
25 }
26
27 @Override
28 public List<Projection> getProjectionsForFilms(int id) {
29 return projectionRepository.getProjectionsForFilms(id);
30 }
31
32 @Override
33 public Projection findById(Integer id_projection) {
34 return projectionRepository.findById(id_projection).orElseThrow(RuntimeException::new);
35 }
36
37
38 @Override
39 public Projection save(LocalDate date_time_start, LocalDate date_time_end, String type_of_technology, Integer id_film) {
40 Film film=filmRepository.findById(id_film).orElseThrow(RuntimeException::new);
41 return projectionRepository.save(new Projection(date_time_start,type_of_technology,date_time_end,film));
42 }
43
44}
Note: See TracBrowser for help on using the repository browser.