@@ -0,0 +1,2460 @@
+package bg.car_wash.areas.service.controller;%0A%0Aimport bg.car_wash.areas.service.entity.Service;%0Aimport bg.car_wash.areas.service.models.bindingModel.ServiceBindingModel;%0Aimport bg.car_wash.areas.service.models.viewModel.ServiceViewModel;%0Aimport bg.car_wash.areas.service.service.ServiceService;%0Aimport bg.car_wash.configurations.site.PageTitle;%0Aimport org.modelmapper.ModelMapper;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Controller;%0Aimport org.springframework.ui.Model;%0Aimport org.springframework.validation.BindingResult;%0Aimport org.springframework.web.bind.annotation.GetMapping;%0Aimport org.springframework.web.bind.annotation.ModelAttribute;%0Aimport org.springframework.web.bind.annotation.PostMapping;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0A%0Aimport javax.validation.Valid;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A@Controller%0A@RequestMapping(%22/service%22)%0Apublic class ServiceController %7B%0A%0A%09private ServiceService serviceService;%0A%09private ModelMapper modelMapper;%0A%0A%09@Autowired%0A%09public ServiceController(ServiceService serviceService, ModelMapper modelMapper) %7B%0A%09%09this.serviceService = serviceService;%0A%09%09this.modelMapper = modelMapper;%0A%09%7D%0A%0A%09@GetMapping(%22/add%22)%0A%09public String getAddServicePage(%0A%09%09%09Model model,%0A%09%09%09@Valid @ModelAttribute ServiceBindingModel serviceBindingModel,%0A%09%09%09BindingResult bindingResult) %7B%0A%09%09model.addAttribute(%22pageTitle%22, PageTitle.SERVICE_ADD_PAGE);%0A%0A%09%09return %22service/service-add%22;%0A%09%7D%0A%0A%09@PostMapping(%22/add%22)%0A%09public String addServicePage(%0A%09%09%09Model model,%0A%09%09%09@Valid @ModelAttribute ServiceBindingModel serviceBindingModel,%0A%09%09%09BindingResult bindingResult) %7B%0A%0A%09%09if (bindingResult.hasErrors()) %7B%0A%09%09%09model.addAttribute(%22pageTitle%22, PageTitle.SERVICE_ADD_PAGE);%0A%09%09%09return %22service/service-add%22;%0A%09%09%7D%0A%0A%09%09Service service = this.modelMapper.map(serviceBindingModel, Service.class);%0A%09%09this.serviceService.createService(service);%0A%0A%09%09return %22redirect:all%22;%0A%09%7D%0A%0A%09@GetMapping(%22/all%22)%0A%09public String getAllServicesPage(Model model) %7B%0A%0A%09%09List%3CServiceViewModel%3E servicesViewModel = new LinkedList%3C%3E();%0A%09%09List%3CService%3E services = this.serviceService.findAllServices();%0A%09%09for (Service service : services) %7B%0A%09%09%09servicesViewModel.add(this.modelMapper.map(service, ServiceViewModel.class));%0A%09%09%7D%0A%0A%09%09model.addAttribute(%22pageTitle%22, PageTitle.SERVICE_ALL_PAGE);%0A%09%09model.addAttribute(%22servicesViewModel%22, servicesViewModel);%0A%0A%09%09return %22service/service-all%22;%0A%09%7D%0A%0A%7D%0A

create ServiceController with mappings for add and all