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

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

fix

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