Search in sources :

Example 1 with Car

use of com.zavada.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class UserController method createAdvertisementForm.

@PostMapping("/{userId}/create")
public String createAdvertisementForm(@ModelAttribute("advModel") CreateAdvRequest request, @PathVariable("userId") int userId) throws IOException {
    UserEntity entity = userService.findUserById(userId);
    Car car = CarMapper.advRequestToCar(request);
    car.setUser(entity);
    carService.saveCar(car);
    CustomFileUtils.createFolder("car_" + car.getId());
    CustomFileUtils.createImage("car_" + car.getId(), request.getCarImage());
    return "redirect:/user";
}
Also used : Car(com.zavada.entity.Car) UserEntity(com.zavada.entity.UserEntity) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with Car

use of com.zavada.entity.Car in project Logos_Materials_October_2017 by VolodymyrZavada.

the class CarMapper method advRequestToCar.

public static Car advRequestToCar(CreateAdvRequest advRequest) {
    Car car = new Car();
    car.setMake(advRequest.getMake());
    car.setModel(advRequest.getModel());
    car.setPrice(advRequest.getPrice());
    car.setModelYear(advRequest.getModelYear());
    car.setColor(advRequest.getColor());
    car.setFuelType(advRequest.getFuelType());
    car.setEngineCapacity(advRequest.getEngineCapacity());
    car.setBodyType(advRequest.getBodyType());
    car.setUser(advRequest.getEntity());
    car.setCarImage(advRequest.getCarImage().getOriginalFilename());
    return car;
}
Also used : Car(com.zavada.entity.Car)

Aggregations

Car (com.zavada.entity.Car)2 UserEntity (com.zavada.entity.UserEntity)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1