source: src/main/java/com/example/moviezone/service/Impl/CustomerIsInterestedInEventImpl.java@ 7215773

Last change on this file since 7215773 was ef84238, checked in by DenicaKj <dkorvezir@…>, 21 months ago

Interested in event

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package com.example.moviezone.service.Impl;
2
3import com.example.moviezone.model.Customer;
4import com.example.moviezone.model.Event;
5import com.example.moviezone.model.manytomany.CustomerIsInterestedInEvent;
6import com.example.moviezone.repository.CustomerIsInterestedInEventRepository;
7import com.example.moviezone.service.CustomerIsInterestedInEventService;
8import org.springframework.stereotype.Service;
9
10@Service
11public class CustomerIsInterestedInEventImpl implements CustomerIsInterestedInEventService {
12 private final CustomerIsInterestedInEventRepository customerIsInterestedInEventRepository;
13
14 public CustomerIsInterestedInEventImpl(CustomerIsInterestedInEventRepository customerIsInterestedInEventRepository) {
15 this.customerIsInterestedInEventRepository = customerIsInterestedInEventRepository;
16 }
17
18 @Override
19 public CustomerIsInterestedInEvent add(Integer id_customer, Integer id_event) {
20 CustomerIsInterestedInEvent customerIsInterestedInEvent=new CustomerIsInterestedInEvent(id_customer,id_event);
21 return customerIsInterestedInEventRepository.save(customerIsInterestedInEvent);
22 }
23
24 @Override
25 public void delete(Customer customer, Event event) {
26 CustomerIsInterestedInEvent customerIsInterestedInEvent=findByCustomerAndEvent(customer,event);
27 customerIsInterestedInEventRepository.delete(customerIsInterestedInEvent);
28 }
29
30 @Override
31 public CustomerIsInterestedInEvent findByCustomerAndEvent(Customer customer, Event event) {
32 return customerIsInterestedInEventRepository.findFirstByIdeventAndAndIdcustomer(event.getId_event(),customer.getId_user());
33 }
34}
Note: See TracBrowser for help on using the repository browser.