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";
}
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;
}
Aggregations