Ignore:
Timestamp:
08/24/23 02:28:14 (15 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
bcb4acc
Parents:
40935d3
Message:

fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/service/Impl/ProjectionServiceImpl.java

    r40935d3 r1e7126f  
    11package com.example.moviezone.service.Impl;
    22
     3import com.example.moviezone.model.Discount;
    34import com.example.moviezone.model.Film;
    45import com.example.moviezone.model.Projection;
     6import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
     7import com.example.moviezone.repository.DiscountRepository;
    58import com.example.moviezone.repository.FilmRepository;
     9import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
    610import com.example.moviezone.repository.ProjectionRepository;
    711import com.example.moviezone.service.ProjectionService;
     
    913
    1014import java.time.LocalDate;
     15import java.time.LocalDateTime;
    1116import java.util.List;
    1217
     
    1419public class ProjectionServiceImpl implements ProjectionService {
    1520    private final ProjectionRepository projectionRepository;
     21    private final ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository;
    1622    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) {
    1825        this.projectionRepository = projectionRepository;
     26        this.projectionIsPlayedInRoomRepository = projectionIsPlayedInRoomRepository;
    1927        this.filmRepository = filmRepository;
     28        this.discountRepository = discountRepository;
    2029    }
    2130
     
    3140
    3241    @Override
     42    public List<Projection> getProjectionsNow() {
     43        return projectionRepository.getProjectionsNow();
     44    }
     45
     46    @Override
    3347    public Projection findById(Integer id_projection) {
    3448        return projectionRepository.findById(id_projection).orElseThrow(RuntimeException::new);
     
    3751
    3852    @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) {
    4054       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;
    4259    }
    4360
Note: See TracChangeset for help on using the changeset viewer.