Index: src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java
===================================================================
--- src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java	(revision 3ded84dfbf8ff25bf27cc822ac97b84a063fa95a)
+++ src/main/java/com/wediscussmovies/project/web/controller/ReplyController.java	(revision 5b447b0d2e718cbed66c944e78e18dd0a5d8bbe3)
@@ -1,16 +1,20 @@
 package com.wediscussmovies.project.web.controller;
 
-import com.wediscussmovies.project.model.*;
+import com.wediscussmovies.project.LoggedUser;
+import com.wediscussmovies.project.model.Reply;
+import com.wediscussmovies.project.model.User;
+import com.wediscussmovies.project.model.primarykeys.ReplyPK;
 import com.wediscussmovies.project.service.ReplyService;
+import org.springframework.security.authentication.AnonymousAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
-import java.util.Optional;
 
 @Controller
+@RequestMapping("/replies")
 public class ReplyController {
     private final ReplyService replyService;
@@ -20,24 +24,62 @@
     }
 
-    @GetMapping("/edit/{id}")
-    public String getReplyEdit(@PathVariable Long id, Model model){
-        Optional<Reply> reply = replyService.findById(id);
-        if(reply.isEmpty())
-            return "redirect:/movies";
-        model.addAttribute("reply", reply.get());
-        model.addAttribute("templateContext", "replyEdit");
+    @GetMapping("/add/{discussionId}")
+    public String addForm(@PathVariable Integer discussionId, Model model){
+        model.addAttribute("discussionId",discussionId);
+        model.addAttribute("contentTemplate","repliesAdd");
         return "template";
     }
 
-    @PostMapping("/edit/confirm/{id}")
-    public String getReplyEdit(@PathVariable Long id, @RequestParam String text){
-        Optional<Reply> replyOp = replyService.findById(id);
-        if(replyOp.isEmpty())
-            return "redirect:/discussions";
-        Reply reply = replyOp.get();
-        replyService.delete(reply);
-        reply.setText(text);
-        replyService.save(reply);
-        return "redirect:/discussions/"+reply.getDiscussionId();
+    @GetMapping("/edit/{discussionId}/{replyId}")
+    public String editForm(@PathVariable Integer discussionId,@PathVariable Integer replyId, Model model){
+
+        try {
+            Reply reply = replyService.findById(discussionId,replyId);
+            model.addAttribute("reply", reply);
+            model.addAttribute("contentTemplate", "repliesAdd");
+            return "template";
+
+
+        }catch (RuntimeException exc){
+            return "redirect:/discussions?error="+exc.getMessage();
+
+        }
     }
+    @PostMapping("/save")
+    public String saveReply(
+            @RequestParam Integer discussionId,
+            @RequestParam String text){
+
+        try {
+
+            this.replyService.save(discussionId,text, LoggedUser.getLoggedUser());
+            return "redirect:/discussions/"+discussionId;
+
+        }
+        catch (RuntimeException exc){
+            return "redirect:/discussions?error="+exc.getMessage();
+
+        }
+    }
+
+    @PostMapping("/save/{replyId}")
+    public String editReply(
+                            @PathVariable Integer replyId,
+                            @RequestParam Integer discussionId,
+                            @RequestParam String text){
+
+        /*
+            1. Da se realizira so ajax baranje na restController
+         */
+        try {
+            Reply reply = replyService.edit(replyId,discussionId, text);
+
+            return "redirect:/discussions/" + reply.getDiscussion().getDiscussionId();
+        }
+        catch (RuntimeException exc){
+            return "redirect:/discussions?error="+exc.getMessage();
+        }
+
+    }
+
 }
