package bg.car_wash;

import bg.car_wash.areas.user.service.UserService;
import bg.car_wash.configurations.database.InsertCars;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;
import java.io.FileNotFoundException;

@SpringBootApplication
public class CarWashApplication {

	@Autowired
	private UserService userService;

	public static void main(String[] args) {
		SpringApplication.run(CarWashApplication.class, args);
	}

//	@PostConstruct
//	public void initUsers() throws FileNotFoundException {
////		InsertUsers userDefault = new InsertUsers();
////		for (User user : userDefault.getUsers()) {
////			this.userService.createUser(user);
////		}
//
//		InsertCars insertCars = new InsertCars();
//	}

	@Bean
	public ModelMapper getModelMapper() {
		return new ModelMapper();
	}

}

@@ -15,16 +15,167 @@
 _wash;%0A%0A
+import bg.car_wash.areas.car.entity.CarMakeModel;%0Aimport bg.car_wash.areas.car.service.CarMakeModelService;%0Aimport bg.car_wash.areas.user.entity.User;%0A
 import b
@@ -272,16 +272,72 @@
 rtCars;%0A
+import bg.car_wash.configurations.database.InsertUsers;%0A
 import o
@@ -676,16 +676,39 @@
 ception;
+%0Aimport java.util.List;
 %0A%0A@Sprin
@@ -806,16 +806,79 @@
 rvice;%0A%0A
+%09@Autowired%0A%09private CarMakeModelService carMakeModelService;%0A%0A
 %09public 
@@ -972,18 +972,16 @@
 s);%0A%09%7D%0A%0A
-//
 %09@PostCo
@@ -988,18 +988,16 @@
 nstruct%0A
-//
 %09public 
@@ -1044,20 +1044,80 @@
 ption %7B%0A
-////
+%09%09//create 6 default users in DB%0A%09%09if (checkUserDbIsEmpty()) %7B%0A%09
 %09%09Insert
@@ -1155,20 +1155,17 @@
 sers();%0A
-////
+%09
 %09%09for (U
@@ -1201,20 +1201,17 @@
 rs()) %7B%0A
-////
+%09
 %09%09%09this.
@@ -1244,67 +1244,615 @@
 r);%0A
-////%09%09%7D%0A//%0A//%09%09InsertCars insertCars = new InsertCars();%0A//
+%09%09%09%7D%0A%09%09%7D%0A%0A%09%09//create all cars with models and makes in DB%0A%09%09if(checkCarMakeModelDbIsEmpty()) %7B%0A%09%09%09InsertCars insertCars = new InsertCars();%0A%09%09%09List%3CCarMakeModel%3E carMakeModels = insertCars.readJsonFile();%0A%09%09%09for (CarMakeModel carMakeModel : carMakeModels) %7B%0A%09%09%09%09this.carMakeModelService.createCar(carMakeModel);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09private boolean checkCarMakeModelDbIsEmpty() %7B%0A%09%09if(this.carMakeModelService.findAllCarMakeModel().isEmpty()) %7B%0A%09%09%09return true;%0A%09%09%7D%0A%0A%09%09return false;%0A%09%7D%0A%0A%09private boolean checkUserDbIsEmpty() %7B%0A%09%09if (this.userService.findAllUsers().isEmpty()) %7B%0A%09%09%09return true;%0A%09%09%7D%0A%0A%09%09return false;%0A
 %09%7D%0A%0A

insert default 6 users with all workers roles in database and insert many car model and make (1900-2000) in database