1 | package com.example.moviezone.service.Impl;
|
---|
2 |
|
---|
3 | import com.example.moviezone.model.Event;
|
---|
4 | import com.example.moviezone.repository.EventRepository;
|
---|
5 | import com.example.moviezone.service.EventService;
|
---|
6 | import org.springframework.stereotype.Service;
|
---|
7 |
|
---|
8 | import java.time.LocalDate;
|
---|
9 | import java.util.Collections;
|
---|
10 | import java.util.List;
|
---|
11 | import java.util.Optional;
|
---|
12 |
|
---|
13 | @Service
|
---|
14 | public class EventServiceImpl implements EventService {
|
---|
15 | private final EventRepository eventRepository;
|
---|
16 |
|
---|
17 | public EventServiceImpl(EventRepository eventRepository) {
|
---|
18 | this.eventRepository = eventRepository;
|
---|
19 | }
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | public List<Event> findAllEvents() {
|
---|
23 | return eventRepository.findAll();
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public Event save(LocalDate start_date, String theme, String duration, String repeating,String img_url) {
|
---|
28 | return eventRepository.save(new Event(theme,duration,repeating,start_date,img_url));
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public List<Event> getEventsNow() {
|
---|
33 | return eventRepository.getFilmsFromCinemaNow();
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public List<Event> getEventsFromCinema(int id) {
|
---|
38 | return eventRepository.getFilmsFromCinema(id);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public Optional<Event> getEventById(Long id) {
|
---|
43 | return eventRepository.findAllById(Collections.singleton(id.intValue())).stream().findFirst();
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public List<Event> getEventsForCustomer(int id) {
|
---|
48 | return eventRepository.getEventsForCustomer(id);
|
---|
49 | }
|
---|
50 | }
|
---|