1 | package com.example.moviezone.service.Impl;
|
---|
2 |
|
---|
3 | import com.example.moviezone.model.*;
|
---|
4 | import com.example.moviezone.repository.TicketRepository;
|
---|
5 | import com.example.moviezone.service.TicketService;
|
---|
6 | import org.springframework.stereotype.Service;
|
---|
7 |
|
---|
8 | import java.time.LocalDate;
|
---|
9 | import java.util.List;
|
---|
10 |
|
---|
11 | @Service
|
---|
12 | public class TicketServiceImpl implements TicketService {
|
---|
13 | private final TicketRepository ticketRepository;
|
---|
14 |
|
---|
15 | public TicketServiceImpl(TicketRepository ticketRepository) {
|
---|
16 | this.ticketRepository = ticketRepository;
|
---|
17 | }
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public List<Ticket> findAllTickets() {
|
---|
21 | return ticketRepository.findAll();
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public List<Ticket> findAllByCustomer(Customer customer) {
|
---|
26 | return ticketRepository.findAllByCustomer(customer);
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public Ticket saveWithDiscount(LocalDate date, Customer customer, Projection projection, Discount discount, Seat seat) {
|
---|
31 | Ticket t=new Ticket(date,customer,projection,discount,seat);
|
---|
32 | return ticketRepository.save(t);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public Ticket saveWithout(LocalDate date, Customer customer, Projection projection, Seat seat) {
|
---|
37 | Ticket t=new Ticket(date,customer,projection,seat);
|
---|
38 | return ticketRepository.save(t);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public Ticket save(long price, Customer customer) {
|
---|
43 | return ticketRepository.save(new Ticket(price,customer));
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public Integer priceForTicket(int id) {
|
---|
48 | return ticketRepository.getPriceForTicket(id);
|
---|
49 | }
|
---|
50 | }
|
---|