Index: src/main/java/com/example/autopartz/config/WebSecurityConfig.java
===================================================================
--- src/main/java/com/example/autopartz/config/WebSecurityConfig.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/config/WebSecurityConfig.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -29,5 +29,5 @@
                 .authorizeRequests()
                 .antMatchers("/", "/products", "/services", "/filtered", "/login", "/register","/registerWarehouseman","/finishRegister","/test/*","/access_denied").permitAll()
-                .antMatchers("/orders","/repairs","/reviews","/part/*","/currentOrder","/addCarSampleForUser").hasRole("CLIENT")
+                .antMatchers("/orders","/repairs","/reviews","/part/*","/currentOrder","/addCarSampleForUser","/repairs/addReview/*").hasRole("CLIENT")
                 .antMatchers("/viewUsers","/approve/*").hasRole("ADMIN")
                 .anyRequest()
Index: src/main/java/com/example/autopartz/controller/PartController.java
===================================================================
--- src/main/java/com/example/autopartz/controller/PartController.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/controller/PartController.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -103,8 +103,10 @@
     public void chooseRepairShop(@RequestParam Integer rs,HttpSession session, HttpServletResponse response){
         Order o = (Order) session.getAttribute("order");
-        CarSample cs = (CarSample)session.getAttribute("car");
+        CarSample cs = carSampleRepository.findById((Integer)session.getAttribute("carVin")).get();
         ServiceBook sb = serviceBookRepository.findByCarSample(cs);
         RepairShop repairShop = repairShopService.getById(rs);
         repairRepository.save(new Repair(o,repairShop,sb));
+//        o.setOrder_status("finished");
+//        orderService.save(o);
         session.removeAttribute("order");
         try {
@@ -123,4 +125,6 @@
         Deliveryman dm = deliverymanList.get(deliverer);
         deliveryRepository.save(new Delivery("in progress",address,dm,o));
+//        o.setOrder_status("finished");
+//        orderService.save(o);
         session.removeAttribute("order");
         try {
Index: src/main/java/com/example/autopartz/controller/UserController.java
===================================================================
--- src/main/java/com/example/autopartz/controller/UserController.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/controller/UserController.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -1,20 +1,19 @@
 package com.example.autopartz.controller;
 
-import com.example.autopartz.model.CarSample;
-import com.example.autopartz.model.Client;
-import com.example.autopartz.model.ServiceBook;
+import com.example.autopartz.model.*;
+import com.example.autopartz.model.views.RepairsForUser;
 import com.example.autopartz.repository.*;
 import com.example.autopartz.service.CarService;
+import com.example.autopartz.service.RepairService;
 import com.example.autopartz.service.UserService;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 @Controller
@@ -28,5 +27,12 @@
     private final CarSampleRepository carSampleRepository;
     private final ServiceBookRepository serviceBookRepository;
-    public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository, UserService userService, CarService carService, CarSampleRepository carSampleRepository, ServiceBookRepository serviceBookRepository) {
+    private final RepairService repairService;
+    private final ReviewRepository reviewRepository;
+    private final RepairRepository repairRepository;
+    private final OrderRepository orderRepository;
+
+    public UserController(OrdersForUserRepository ordersForUserRepository, RepairsForUserRepository repairsForUserRepository, ReviewsForUserRepository reviewsForUserRepository, UserService userService, CarService carService, CarSampleRepository carSampleRepository, ServiceBookRepository serviceBookRepository, RepairService repairService, ReviewRepository reviewRepository,
+                          RepairRepository repairRepository,
+                          OrderRepository orderRepository) {
         this.ordersForUserRepository = ordersForUserRepository;
         this.repairsForUserRepository = repairsForUserRepository;
@@ -36,4 +42,8 @@
         this.carSampleRepository = carSampleRepository;
         this.serviceBookRepository = serviceBookRepository;
+        this.repairService = repairService;
+        this.reviewRepository = reviewRepository;
+        this.repairRepository = repairRepository;
+        this.orderRepository = orderRepository;
     }
     @GetMapping("orders")
@@ -48,4 +58,17 @@
         Integer id = userService.findByUsername(request.getRemoteUser()).getId();
         model.addAttribute("userRepairs",repairsForUserRepository.findAllByUserid(id));
+        List<Boolean> hasReview = new ArrayList<>(100);
+        for (int i = 0; i < orderRepository.findAll().size(); i++) {
+            hasReview.add(false);
+        }
+        for(RepairsForUser rfu: repairsForUserRepository.findAll()){
+            if(reviewRepository.findByRepair(repairService.findById(rfu.getRepairid()))==null){
+                hasReview.set(rfu.getRepairid(),false);
+            }
+            else {
+                hasReview.set(rfu.getRepairid(),true);
+            }
+        }
+        model.addAttribute("hasReview", hasReview);
         model.addAttribute("bodyContent","repairsForUser");
         return "master-template";
@@ -78,3 +101,22 @@
         }
     }
+    @GetMapping("/repairs/addReview/{id}")
+    public String addReviewFor(@PathVariable Integer id, Model model){
+        model.addAttribute("bodyContent","addReviewPage");
+        model.addAttribute("repair", repairService.findById(id));
+        return "master-template";
+    }
+    @PostMapping("/repairs/addReview/{id}")
+    public void addReview(@PathVariable Integer id, @RequestParam Integer rating, @RequestParam(required = false) String comment,
+                          Model model, HttpServletResponse response, HttpServletRequest request){
+        Client client = (Client) userService.findByUsername(request.getRemoteUser());
+        Repair repair = repairService.findById(id);
+        reviewRepository.save(new Review(rating,
+                comment==null ? "" : comment, repair,client));
+        try {
+            response.sendRedirect("/repairs");
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }
Index: src/main/java/com/example/autopartz/model/Repair.java
===================================================================
--- src/main/java/com/example/autopartz/model/Repair.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/model/Repair.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -18,5 +18,6 @@
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
-    Integer ID_repair;
+    @Column(name = "ID_repair")
+    Integer id;
     @OneToOne
     @JoinColumn(name = "id_order")
@@ -34,5 +35,4 @@
         this.serviceBook = serviceBook;
     }
-
     @Override
     public boolean equals(Object o) {
@@ -40,5 +40,5 @@
         if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
         Repair repair = (Repair) o;
-        return ID_repair != null && Objects.equals(ID_repair, repair.ID_repair);
+        return id != null && Objects.equals(id, repair.id);
     }
 
Index: src/main/java/com/example/autopartz/model/Review.java
===================================================================
--- src/main/java/com/example/autopartz/model/Review.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/model/Review.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -7,8 +7,5 @@
 import org.hibernate.Hibernate;
 
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
+import javax.persistence.*;
 import java.util.Objects;
 
@@ -20,4 +17,5 @@
 public class Review {
     @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     Integer ID_review;
     Integer review_rating;
@@ -29,4 +27,11 @@
     @JoinColumn(name = "id_user")
     Client client;
+
+    public Review(Integer review_rating, String review_comment, Repair repair, Client client) {
+        this.review_rating = review_rating;
+        this.review_comment = review_comment;
+        this.repair = repair;
+        this.client = client;
+    }
 
     @Override
Index: src/main/java/com/example/autopartz/model/views/RepairsForUser.java
===================================================================
--- src/main/java/com/example/autopartz/model/views/RepairsForUser.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/model/views/RepairsForUser.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -23,14 +23,11 @@
 @Immutable
 @Table(name = "`repairs_for_user`")
-@IdClass(OrdersForUserId.class)
 public class RepairsForUser implements Serializable {
     @Serial
     private static final long serialVersionUID = 1L;
     @Id
+    Integer repairid;
     Integer userid;
-    @Id
     LocalDateTime orderdate;
-    @Id
-    String partname;
     Integer orderid;
     String rsname;
Index: src/main/java/com/example/autopartz/repository/RepairRepository.java
===================================================================
--- src/main/java/com/example/autopartz/repository/RepairRepository.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/repository/RepairRepository.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -4,4 +4,7 @@
 import org.springframework.data.jpa.repository.JpaRepository;
 
+import java.util.List;
+
 public interface RepairRepository extends JpaRepository<Repair,Integer> {
+    List<Repair> findAllById(Integer id);
 }
Index: src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java
===================================================================
--- src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/repository/RepairsForUserRepository.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -9,5 +9,5 @@
 
 @Repository
-public interface RepairsForUserRepository extends JpaRepository<RepairsForUser, OrdersForUserId> {
+public interface RepairsForUserRepository extends JpaRepository<RepairsForUser, Integer> {
     List<RepairsForUser> findAllByUserid(Integer userid);
 }
Index: src/main/java/com/example/autopartz/repository/ReviewRepository.java
===================================================================
--- src/main/java/com/example/autopartz/repository/ReviewRepository.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/repository/ReviewRepository.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -0,0 +1,9 @@
+package com.example.autopartz.repository;
+
+import com.example.autopartz.model.Repair;
+import com.example.autopartz.model.Review;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface ReviewRepository extends JpaRepository<Review,Integer> {
+    Review findByRepair(Repair repair);
+}
Index: src/main/java/com/example/autopartz/service/OrderService.java
===================================================================
--- src/main/java/com/example/autopartz/service/OrderService.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/service/OrderService.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -10,4 +10,5 @@
     Order create(Client user);
     Order findById(Integer id);
+    void save(Order o);
 }
 
Index: src/main/java/com/example/autopartz/service/RepairService.java
===================================================================
--- src/main/java/com/example/autopartz/service/RepairService.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/service/RepairService.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -0,0 +1,8 @@
+package com.example.autopartz.service;
+
+import com.example.autopartz.model.Repair;
+
+
+public interface RepairService {
+    Repair findById(Integer id);
+}
Index: src/main/java/com/example/autopartz/service/impl/OrderServiceImpl.java
===================================================================
--- src/main/java/com/example/autopartz/service/impl/OrderServiceImpl.java	(revision f484b14ac6839719d4237822f088e088abec9846)
+++ src/main/java/com/example/autopartz/service/impl/OrderServiceImpl.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -30,3 +30,8 @@
         return orderRepository.findById(id).get();
     }
+
+    @Override
+    public void save(Order o) {
+        orderRepository.save(o);
+    }
 }
Index: src/main/java/com/example/autopartz/service/impl/RepairServiceImpl.java
===================================================================
--- src/main/java/com/example/autopartz/service/impl/RepairServiceImpl.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
+++ src/main/java/com/example/autopartz/service/impl/RepairServiceImpl.java	(revision d4b888e8c58f07ca9c34c64e3184cceecd9b65a8)
@@ -0,0 +1,20 @@
+package com.example.autopartz.service.impl;
+
+import com.example.autopartz.model.Repair;
+import com.example.autopartz.repository.RepairRepository;
+import com.example.autopartz.service.RepairService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RepairServiceImpl implements RepairService {
+    private final RepairRepository repairRepository;
+
+    public RepairServiceImpl(RepairRepository repairRepository) {
+        this.repairRepository = repairRepository;
+    }
+
+    @Override
+    public Repair findById(Integer id) {
+        return repairRepository.findById(id).get();
+    }
+}
