source: source/MovieZilla-master/src/main/java/com/example/demo/service/ServiceImpl/ReservationServiceImpl.java

Last change on this file was fc7ec52, checked in by darkopopovski <darkopopovski39@…>, 2 years ago

all files

  • Property mode set to 100644
File size: 3.4 KB
Line 
1package com.example.demo.service.ServiceImpl;
2
3import com.example.demo.model.*;
4import com.example.demo.model.Client.Client;
5import com.example.demo.model.Client.ClientCompositeKey;
6import com.example.demo.model.Reservation.Reservations;
7import com.example.demo.model.Seat.Seat;
8import com.example.demo.model.Seat.SeatCompositeKey;
9import com.example.demo.repository.*;
10import com.example.demo.service.MovieProjectionService;
11import com.example.demo.service.ReservationService;
12import org.springframework.stereotype.Service;
13import org.springframework.transaction.annotation.Transactional;
14import java.util.Optional;
15
16@Service
17public class ReservationServiceImpl implements ReservationService {
18 private final PaymentTypeRepository paymentTypeRepository;
19 private final ClientRepository clientRepository;
20 private final SeatRepository seatRepository;
21 private final AuditoriumRepository auditoriumRepository;
22 private final UserRepository userRepository;
23 private final MovieProjectionService movieProjectionService;
24 private final PaymentRepository paymentRepository;
25 private final ReservationsRepository reservationsRepository;
26 public ReservationServiceImpl(PaymentTypeRepository paymentTypeRepository, ClientRepository clientRepository, SeatRepository seatRepository, AuditoriumRepository auditoriumRepository, UserRepository userRepository, MovieProjectionService movieProjectionService, PaymentRepository paymentRepository, ReservationsRepository reservationsRepository) {
27 this.paymentTypeRepository = paymentTypeRepository;
28 this.clientRepository = clientRepository;
29 this.seatRepository = seatRepository;
30 this.auditoriumRepository = auditoriumRepository;
31 this.userRepository = userRepository;
32 this.movieProjectionService = movieProjectionService;
33 this.paymentRepository = paymentRepository;
34 this.reservationsRepository = reservationsRepository;
35 }
36
37 @Override
38 @Transactional
39 public Optional<Reservations> save(
40 Integer reservation_id,
41 String reservation_end_date,
42 Integer payment_type_id,
43 Integer user_id,
44 Integer seat_id,
45 Integer auditorium_id,
46 Integer projection_id) {
47
48 PaymentType paymentType = this.paymentTypeRepository.findById(payment_type_id).get();
49
50
51 User user = this.userRepository.findById(String.valueOf(user_id)).get();
52 ClientCompositeKey clientCompositeKey = new ClientCompositeKey();
53 clientCompositeKey.setUser(user);
54 Client client = this.clientRepository.findById(clientCompositeKey).get();
55
56
57 SeatCompositeKey seatCompositeKey = new SeatCompositeKey();
58 seatCompositeKey.setSeat_id(seat_id);
59 Auditorium auditorium = this.auditoriumRepository.findById(auditorium_id).get();
60 seatCompositeKey.setAuditorium(auditorium);
61 Seat seat = seatRepository.findById(seatCompositeKey).get();
62
63 MovieProjection movieProjection = movieProjectionService.findById(projection_id).get();
64
65
66 /*
67 return Optional.of(this.reservationsRepository.save(new Reservations(reservation_id,reservation_end_date,paymentType,
68 seat,client,movieProjection)));
69 }
70
71 */
72 return null;
73 }
74 @Override
75 public Optional<Reservations> findAll() {
76 return this.reservationsRepository.findAllReservations();
77 }
78}
Note: See TracBrowser for help on using the repository browser.