Ignore:
Timestamp:
01/09/24 01:26:08 (10 months ago)
Author:
ppaunovski <paunovskipavel@…>
Branches:
master
Children:
e272096
Parents:
b101b69
Message:

All 3 main use cases implemented.

  1. Starting a commute
  2. Writing a ticket
  3. Starting an instance of a Bus Line
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/mk/ukim/finki/busngo/web/BiletController.java

    rb101b69 rbde8b13  
    11package mk.ukim.finki.busngo.web;
    22
     3import mk.ukim.finki.busngo.model.entities.Patnik;
    34import mk.ukim.finki.busngo.model.enums.BILET_STATUS;
     5import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
    46import mk.ukim.finki.busngo.service.AuthService;
    57import mk.ukim.finki.busngo.service.BiletService;
     8import mk.ukim.finki.busngo.service.PatnikService;
    69import mk.ukim.finki.busngo.service.TipBiletService;
    710import org.springframework.security.core.Authentication;
     
    2124    private final TipBiletService tipBiletService;
    2225    private final AuthService authService;
     26    private final PatnikService patnikService;
    2327
    24     public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService) {
     28    public BiletController(BiletService biletService, TipBiletService tipBiletService, AuthService authService, PatnikService patnikService) {
    2529        this.biletService = biletService;
    2630        this.tipBiletService = tipBiletService;
    2731        this.authService = authService;
     32        this.patnikService = patnikService;
    2833    }
    2934
     
    3136    public String getAllBileti(@RequestParam(required = false) Long id,
    3237                               @RequestParam(required = false) BILET_STATUS status,
    33                                Model model){
     38                               Model model,
     39                               Authentication authentication){
    3440        model.addAttribute("bodyContent", "listBileti");
    35         model.addAttribute("bileti", biletService.listAll());
     41        Patnik patnik = null;
     42        try{
     43            model.addAttribute("bileti", biletService.findAllByPatnikEmail(authentication.getName()));
     44        }
     45        catch (InvalidPatnikIdException e){
     46            model.addAttribute("bodyContent", "listBileti");
     47            model.addAttribute("hasError", true);
     48            model.addAttribute("error", e.getMessage());
     49            return "master-template";
     50        }
     51
    3652        return "master-template";
    3753    }
     
    5066    }
    5167
     68//    @GetMapping("/encode")
     69//    public String encode(){
     70//        biletService.encode();
     71//        return "redirect:/bilet";
     72//    }
     73
    5274}
Note: See TracChangeset for help on using the changeset viewer.