source: src/main/java/com/example/moviezone/service/Impl/SeatServiceImpl.java

Last change on this file was 4173acf, checked in by DenicaKj <dkorvezir@…>, 15 months ago

fix

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[fdc651c]1package com.example.moviezone.service.Impl;
2
[1e7126f]3import com.example.moviezone.model.*;
[8a18cf5]4import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
5import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
6import com.example.moviezone.repository.Projection_RoomRepository;
[fdc651c]7import com.example.moviezone.repository.SeatRepository;
8import com.example.moviezone.service.SeatService;
9import org.springframework.stereotype.Service;
10
[8a18cf5]11import java.util.ArrayList;
[fdc651c]12import java.util.List;
[00fa72f]13import java.util.Optional;
[fdc651c]14
15@Service
16public class SeatServiceImpl implements SeatService {
[00fa72f]17
18
[fdc651c]19 private final SeatRepository seatRepository;
[8a18cf5]20 private final TicketServiceImpl ticketService;
21 private final ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository;
22 private final Projection_RoomRepository projection_roomRepository;
[fdc651c]23
[8a18cf5]24 public SeatServiceImpl(SeatRepository seatRepository, TicketServiceImpl ticketService, ProjectionIsPlayedInRoomRepository projectionIsPlayedInRoomRepository, Projection_RoomRepository projection_roomRepository) {
[fdc651c]25 this.seatRepository = seatRepository;
[8a18cf5]26 this.ticketService = ticketService;
27 this.projectionIsPlayedInRoomRepository = projectionIsPlayedInRoomRepository;
28 this.projection_roomRepository = projection_roomRepository;
[fdc651c]29 }
30
31 @Override
32 public List<Seat> findAllSeats() {
33 return seatRepository.findAll();
34 }
35
36 @Override
37 public List<Seat> findAllByProjection_Room(Projection_Room projection_room) {
[64ee7f4]38 return seatRepository.findAllByProjection(projection_room);
[fdc651c]39 }
[00fa72f]40
41 @Override
[1e7126f]42 public List<Seat> findAllByRoomAndCategory(Projection projection, Projection_Room projectionRoom, Category category) {
[8a18cf5]43 List<Ticket> tickets=ticketService.findAllTickets();
44 List<Seat> seats=seatRepository.findAllByCategoryAndProjection(category,projectionRoom);
[4173acf]45
[8a18cf5]46 for (int i = 0; i < tickets.size(); i++) {
[1e7126f]47 if(tickets.get(i).getProjection()==projection){
[4173acf]48 if(seats.contains(tickets.get(i).getSeat())){
49 seats.remove(tickets.get(i).getSeat());
[8a18cf5]50 }
51 }
52 }
[4173acf]53 return seats;
[00fa72f]54 }
55
56 @Override
57 public Optional<Seat> getSeatById(int id) {
58 return Optional.of(seatRepository.getById(id));
59 }
[fdc651c]60}
Note: See TracBrowser for help on using the repository browser.