- Timestamp:
- 08/24/23 02:28:14 (15 months ago)
- Branches:
- master
- Children:
- bcb4acc
- Parents:
- 40935d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java
r40935d3 r1e7126f 1 1 package com.example.moviezone.service.Impl; 2 2 3 import com.example.moviezone.model.Discount; 3 4 import com.example.moviezone.model.Film; 4 5 import com.example.moviezone.model.Projection; 6 import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom; 7 import com.example.moviezone.repository.DiscountRepository; 5 8 import com.example.moviezone.repository.FilmRepository; 9 import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository; 6 10 import com.example.moviezone.repository.ProjectionRepository; 7 11 import com.example.moviezone.service.ProjectionService; … … 9 13 10 14 import java.time.LocalDate; 15 import java.time.LocalDateTime; 11 16 import java.util.List; 12 17 … … 14 19 public class ProjectionServiceImpl implements ProjectionService { 15 20 private final ProjectionRepository projectionRepository; 21 private final ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository; 16 22 private final FilmRepository filmRepository; 17 public ProjectionServiceImpl(ProjectionRepository projectionRepository, FilmRepository filmRepository) { 23 private final DiscountRepository discountRepository; 24 public ProjectionServiceImpl(ProjectionRepository projectionRepository, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository, FilmRepository filmRepository, DiscountRepository discountRepository) { 18 25 this.projectionRepository = projectionRepository; 26 this.projectionIsPlayedInRoomRepository = projectionIsPlayedInRoomRepository; 19 27 this.filmRepository = filmRepository; 28 this.discountRepository = discountRepository; 20 29 } 21 30 … … 31 40 32 41 @Override 42 public List<Projection> getProjectionsNow() { 43 return projectionRepository.getProjectionsNow(); 44 } 45 46 @Override 33 47 public Projection findById(Integer id_projection) { 34 48 return projectionRepository.findById(id_projection).orElseThrow(RuntimeException::new); … … 37 51 38 52 @Override 39 public Projection save(LocalDate date_time_start, LocalDate date_time_end, String type_of_technology, Integer id_film) {53 public Projection save(LocalDateTime date_time_start, LocalDateTime date_time_end, String type_of_technology, Integer id_film, Integer id_room, Integer id_discount) { 40 54 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)); 55 Discount discount = discountRepository.findById(id_discount).orElseThrow(RuntimeException::new); 56 Projection projection = projectionRepository.save(new Projection(date_time_start,type_of_technology,date_time_end,film,discount)); 57 projectionIsPlayedInRoomRepository.save(new ProjectionIsPlayedInRoom(projection.getId_projection(),id_room)); 58 return projection; 42 59 } 43 60
Note:
See TracChangeset
for help on using the changeset viewer.