@@ -0,0 +1,2527 @@
+package bg.car_wash.areas.activity.controller;%0A%0Aimport bg.car_wash.areas.activity.entity.Activity;%0Aimport bg.car_wash.areas.activity.models.bindingModel.ActivityBindingModel;%0Aimport bg.car_wash.areas.activity.models.viewModel.ActivityViewModel;%0Aimport bg.car_wash.areas.activity.service.ActivityService;%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/activity%22)%0Apublic class ActivityController %7B%0A%0A%09private ActivityService activityService;%0A%0A%09private ModelMapper modelMapper;%0A%0A%09@Autowired%0A%09public ActivityController(ActivityService activityService, ModelMapper modelMapper) %7B%0A%09%09this.activityService = activityService;%0A%09%09this.modelMapper = modelMapper;%0A%09%7D%0A%0A%09@GetMapping(%22/add%22)%0A%09public String getAddActivityPage(%0A%09%09%09Model model,%0A%09%09%09@Valid @ModelAttribute ActivityBindingModel activityBindingModel,%0A%09%09%09BindingResult bindingResult) %7B%0A%09%09model.addAttribute(%22pageTitle%22, PageTitle.ACTIVITY_ADD_PAGE);%0A%0A%09%09return %22activity/activity-add%22;%0A%09%7D%0A%0A%09@PostMapping(%22/add%22)%0A%09public String addActivityPage(%0A%09%09%09Model model,%0A%09%09%09@Valid @ModelAttribute ActivityBindingModel activityBindingModel,%0A%09%09%09BindingResult bindingResult) %7B%0A%0A%09%09if(bindingResult.hasErrors()) %7B%0A%09%09%09model.addAttribute(%22pageTitle%22, PageTitle.ACTIVITY_ADD_PAGE);%0A%09%09%09return %22activity/activity-add%22;%0A%09%09%7D%0A%0A%09%09Activity activity = this.modelMapper.map(activityBindingModel, Activity.class);%0A%0A%09%09this.activityService.createActivity(activity);%0A%0A%09%09return %22redirect:all%22;%0A%09%7D%0A%0A%09@GetMapping(%22/all%22)%0A%09public String getAllActivityPage(Model model) %7B%0A%0A%09%09List%3CActivityViewModel%3E activityViewModelList = new LinkedList%3C%3E();%0A%09%09List%3CActivity%3E activities = this.activityService.findAllActivities();%0A%09%09for (Activity activity : activities) %7B%0A%09%09%09activityViewModelList.add(this.modelMapper.map(activity, ActivityViewModel.class));%0A%09%09%7D%0A%0A%09%09model.addAttribute(%22pageTitle%22, PageTitle.ACTIVITY_ALL_PAGE);%0A%09%09model.addAttribute(%22activitiesViewModel%22, activityViewModelList);%0A%0A%09%09return %22activity/activity-all%22;%0A%09%7D%0A%7D%0A

create ActivityController with add and all mappings