source: src/main/java/mk/ukim/finki/eglas/services/Impl/CandidatesListElectionRealizationServiceImpl.java@ ac151d1

main
Last change on this file since ac151d1 was ac151d1, checked in by David <darsov2@…>, 11 days ago

initial

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package mk.ukim.finki.eglas.services.Impl;
2
3import mk.ukim.finki.eglas.model.CandidatesElectionRealization;
4import mk.ukim.finki.eglas.model.CandidatesListElectionRealization;
5import mk.ukim.finki.eglas.model.ElectionRealization;
6import mk.ukim.finki.eglas.repository.CandidatesListElectionRealizationRepository;
7import mk.ukim.finki.eglas.services.CandidatesListElectionRealizationService;
8import mk.ukim.finki.eglas.services.ElectionRealizationService;
9import org.springframework.stereotype.Service;
10
11import java.util.List;
12@Service
13public class CandidatesListElectionRealizationServiceImpl implements CandidatesListElectionRealizationService {
14 private final CandidatesListElectionRealizationRepository repository;
15 private final ElectionRealizationService electionRealizationService;
16
17 CandidatesListElectionRealizationServiceImpl(CandidatesListElectionRealizationRepository repository,
18 ElectionRealizationService electionRealizationService){
19 this.repository = repository;
20 this.electionRealizationService = electionRealizationService;
21 }
22
23 public CandidatesListElectionRealization findById(Long id){
24 return repository.findById(id).orElseThrow(() -> new RuntimeException("No candidate list election realization found"));
25 }
26 public List<CandidatesListElectionRealization> findAll(){
27 return repository.findAll();
28 }
29
30 public CandidatesListElectionRealization update(Long id){
31 CandidatesListElectionRealization can = (CandidatesListElectionRealization) electionRealizationService.findById(id);
32 return repository.save(can);
33 }
34
35 public void delete(Long id){
36 repository.delete(findById(id));
37 }
38}
Note: See TracBrowser for help on using the repository browser.