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/SeatServiceImpl.java

    r40935d3 r1e7126f  
    11package com.example.moviezone.service.Impl;
    22
    3 import com.example.moviezone.model.Category;
    4 import com.example.moviezone.model.Projection_Room;
    5 import com.example.moviezone.model.Seat;
    6 import com.example.moviezone.model.Ticket;
     3import com.example.moviezone.model.*;
    74import com.example.moviezone.model.manytomany.ProjectionIsPlayedInRoom;
    85import com.example.moviezone.repository.ProjectionIsPlayedInRoomRepository;
     
    4340
    4441    @Override
    45     public List<Seat> findAllByRoomAndCategory(Projection_Room projectionRoom, Category category) {
     42    public List<Seat> findAllByRoomAndCategory(Projection projection, Projection_Room projectionRoom, Category category) {
    4643        List<Ticket> tickets=ticketService.findAllTickets();
    4744        List<Seat> seats=seatRepository.findAllByCategoryAndProjection(category,projectionRoom);
    48         List<Seat> s=new ArrayList<>();
    49         List<Projection_Room> projection_rooms=new ArrayList<>();
     45
    5046        for (int i = 0; i < tickets.size(); i++) {
    51             List<ProjectionIsPlayedInRoom> projectionIsPlayedInRooms= projectionIsPlayedInRoomRepository.findAllByProjectionId(tickets.get(i).getProjection().getId_projection());
    52             for (int j = 0; j < projectionIsPlayedInRooms.size(); j++) {
    53                 projection_rooms.add(projection_roomRepository.getById(projectionIsPlayedInRooms.get(j).getIdroom()));
     47            if(tickets.get(i).getProjection()==projection){
     48                if(seats.contains(tickets.get(i).getSeat())){
     49                    seats.remove(tickets.get(i).getSeat());
     50                }
    5451            }
    5552        }
    56         int f=0;
    57         for (int i = 0; i < seats.size(); i++) {
    58             for (int j = 0; j < tickets.size(); j++) {
    59                 if(seats.get(i).getId_seat().equals(tickets.get(j).getSeat().getId_seat())){
    60                     for (int k = 0; k < projection_rooms.size(); k++) {
    61                         if(seats.get(i).getProjection().getId_room().equals(projection_rooms.get(k).getId_room()))
    62                             f=1;
    63                     }
    64                 }
    65 
    66             }
    67 
    68             if(f==0){
    69                 s.add(seats.get(i));
    70             }
    71             f=0;
    72         }
    73         return s;
     53        return seats;
    7454    }
    7555
Note: See TracChangeset for help on using the changeset viewer.