[11dea8f] | 1 | package com.example.moviezone.service.Impl;
|
---|
| 2 |
|
---|
[00fa72f] | 3 | import com.example.moviezone.model.*;
|
---|
[1b248e4] | 4 | import com.example.moviezone.repository.TicketRepository;
|
---|
[11dea8f] | 5 | import com.example.moviezone.service.TicketService;
|
---|
| 6 | import org.springframework.stereotype.Service;
|
---|
| 7 |
|
---|
[00fa72f] | 8 | import java.time.LocalDate;
|
---|
[11dea8f] | 9 | import java.util.List;
|
---|
| 10 |
|
---|
| 11 | @Service
|
---|
| 12 | public class TicketServiceImpl implements TicketService {
|
---|
[1b248e4] | 13 | private final TicketRepository ticketRepository;
|
---|
| 14 |
|
---|
| 15 | public TicketServiceImpl(TicketRepository ticketRepository) {
|
---|
| 16 | this.ticketRepository = ticketRepository;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
[11dea8f] | 19 | @Override
|
---|
| 20 | public List<Ticket> findAllTickets() {
|
---|
[1b248e4] | 21 | return ticketRepository.findAll();
|
---|
[11dea8f] | 22 | }
|
---|
| 23 |
|
---|
| 24 | @Override
|
---|
[1b248e4] | 25 | public List<Ticket> findAllByCustomer(Customer customer) {
|
---|
| 26 | return ticketRepository.findAllByCustomer(customer);
|
---|
[11dea8f] | 27 | }
|
---|
[3242ef4] | 28 |
|
---|
[00fa72f] | 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 |
|
---|
[3242ef4] | 41 | @Override
|
---|
| 42 | public Ticket save(long price, Customer customer) {
|
---|
| 43 | return ticketRepository.save(new Ticket(price,customer));
|
---|
| 44 | }
|
---|
[00fa72f] | 45 |
|
---|
| 46 | @Override
|
---|
| 47 | public Integer priceForTicket(int id) {
|
---|
| 48 | return ticketRepository.getPriceForTicket(id);
|
---|
| 49 | }
|
---|
[1e7126f] | 50 |
|
---|
| 51 | @Override
|
---|
| 52 | public void delete(int id) {
|
---|
| 53 | ticketRepository.deleteById(id);
|
---|
| 54 | }
|
---|
[11dea8f] | 55 | }
|
---|