Search in sources :

Example 1 with Car

use of ua.springboot.web.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarController method showCarsByMake.

@GetMapping("/cars/filter")
public String showCarsByMake(@PageableDefault Pageable pageable, @RequestParam("search") String search, Model model) {
    CarFilter filter = null;
    if (search != null) {
        filter = new CarFilter(search);
    }
    Page<Car> cars = carService.findAllCarsByMake(pageable, filter);
    model.addAttribute("carsList", cars.getContent());
    return "car/cars";
}
Also used : CarFilter(ua.springboot.web.domain.CarFilter) Car(ua.springboot.web.entity.Car) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with Car

use of ua.springboot.web.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarController method generateRandomCars.

@GetMapping("sachascjksacnk/generate/random")
public String generateRandomCars() {
    for (int i = 0; i < 800; i++) {
        Car car = new Car();
        car.setMake("CarMake #" + i);
        car.setModel("CarModel #" + i);
        car.setColor(colorService.findColorById(1));
        carService.saveCar(car);
    }
    return "redirect:/car/cars";
}
Also used : Car(ua.springboot.web.entity.Car) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with Car

use of ua.springboot.web.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarController method showAddCarForm.

@GetMapping("/create")
public String showAddCarForm(Model model) {
    model.addAttribute("carModel", new Car());
    model.addAttribute("colorsList", colorService.findAllColors());
    return "car/create";
}
Also used : Car(ua.springboot.web.entity.Car) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with Car

use of ua.springboot.web.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarController method showCreateCarPage.

@GetMapping("/create")
public String showCreateCarPage(Model model) {
    model.addAttribute("carModel", new Car());
    model.addAttribute("colorsList", colorService.findAllColors());
    return "car/create";
}
Also used : Car(ua.springboot.web.entity.Car) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with Car

use of ua.springboot.web.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarController method showCarsByTitleFilter.

@GetMapping("/cars/search")
public String showCarsByTitleFilter(@PageableDefault Pageable pageable, Model model, @RequestParam("search") String search) {
    Page<Car> page = carService.findCarByMake(pageable, new CarMakeFilter(search));
    model.addAttribute("carsList", page.getContent());
    return "car/cars";
}
Also used : Car(ua.springboot.web.entity.Car) CarMakeFilter(ua.springboot.web.domain.CarMakeFilter) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)6 Car (ua.springboot.web.entity.Car)6 CarFilter (ua.springboot.web.domain.CarFilter)1 CarMakeFilter (ua.springboot.web.domain.CarMakeFilter)1