Index: src/main/java/com/wediscussmovies/project/model/Discussion.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Discussion.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/Discussion.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,3 +1,5 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.*;
@@ -5,4 +7,5 @@
 import java.util.List;
 
+@Data
 @Entity
 public class Discussion {
Index: src/main/java/com/wediscussmovies/project/model/Genre.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Genre.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/Genre.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,3 +1,5 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.Column;
@@ -6,4 +8,5 @@
 import javax.persistence.Id;
 
+@Data
 @Entity(name="genres")
 public class Genre {
@@ -15,4 +18,11 @@
     @Column(name="genre_type", length = 100, nullable = false, unique = true)
     private String genre_type;
+
+    public Genre(String genreName) {
+        this.genre_type = genreName;
+    }
+
+    public Genre() {
+    }
 }
 
Index: src/main/java/com/wediscussmovies/project/model/Movie.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Movie.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/Movie.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,8 +1,11 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.*;
 import java.sql.Date;
+import java.util.Comparator;
 import java.util.List;
-
+@Data
 @Entity(name="movies")
 public class Movie {
@@ -36,4 +39,36 @@
     @ManyToMany(mappedBy = "movie_genres")
     private List<Genre> genres;
+
+    public boolean isFromGenre(Genre genre){
+        for(Genre g: genres){
+            if(g.getGenre_id() == genre.getGenre_id())
+                return true;
+        }
+        return false;
+    }
+    public boolean hasActor(Person p){
+        for(Person person: actors){
+            if(person.getPerson_id() == p.getPerson_id())
+                return true;
+        }
+        return false;
+    }
+
+    public boolean isDirectedBy(Person p){
+        return director.getPerson_id() == p.getPerson_id();
+    }
+
+    public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
+
+    public Movie(String title, String description, String image_url, Date airing_date, float imdb_rating, Person director, List<Person> actors, List<Genre> genres) {
+        Title = title;
+        this.description = description;
+        this.image_url = image_url;
+        this.airing_date = airing_date;
+        this.imdb_rating = imdb_rating;
+        this.director = director;
+        this.actors = actors;
+        this.genres = genres;
+    }
 }
 
Index: src/main/java/com/wediscussmovies/project/model/Person.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Person.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/Person.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,3 +1,5 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.*;
@@ -5,4 +7,5 @@
 import java.util.List;
 
+@Data
 @Entity(name="persons")
 public class Person {
Index: src/main/java/com/wediscussmovies/project/model/Reply.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/Reply.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/Reply.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,7 +1,10 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.*;
 import java.sql.Date;
 
+@Data
 @Entity(name="replies")
 public class Reply {
Index: src/main/java/com/wediscussmovies/project/model/User.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/User.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/model/User.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,7 +1,10 @@
 package com.wediscussmovies.project.model;
+
+import lombok.Data;
 
 import javax.persistence.*;
 import java.util.List;
 
+@Data
 @Entity(name="users")
 public class User {
Index: src/main/java/com/wediscussmovies/project/model/exception/MovieIdNotFoundException.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/exception/MovieIdNotFoundException.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
+++ src/main/java/com/wediscussmovies/project/model/exception/MovieIdNotFoundException.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -0,0 +1,7 @@
+package com.wediscussmovies.project.model.exception;
+
+public class MovieIdNotFoundException extends RuntimeException{
+    public MovieIdNotFoundException(Integer id) {
+        super("Movie with id {"+id+"} was not found.");
+    }
+}
Index: src/main/java/com/wediscussmovies/project/model/exception/NotEnoughArgumentsException.java
===================================================================
--- src/main/java/com/wediscussmovies/project/model/exception/NotEnoughArgumentsException.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
+++ src/main/java/com/wediscussmovies/project/model/exception/NotEnoughArgumentsException.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -0,0 +1,4 @@
+package com.wediscussmovies.project.model.exception;
+
+public class NotEnoughArgumentsException {
+}
Index: src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
===================================================================
--- src/main/java/com/wediscussmovies/project/repository/GenreRepository.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/repository/GenreRepository.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -5,5 +5,8 @@
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface GenreRepository extends JpaRepository<Genre, Integer> {
+    public List<Genre> findAllByGenre_typeLike(String genre_type);
 }
Index: src/main/java/com/wediscussmovies/project/repository/PersonRepository.java
===================================================================
--- src/main/java/com/wediscussmovies/project/repository/PersonRepository.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/repository/PersonRepository.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -2,8 +2,15 @@
 
 import com.wediscussmovies.project.model.Person;
+import com.wediscussmovies.project.model.PersonType;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Optional;
 
 @Repository
 public interface PersonRepository extends JpaRepository<Person, Integer> {
+    public List<Person> findAllByPersonType(PersonType type);
+    public Optional<Person> findPersonByPerson_idAndPersonType(Integer id, PersonType type);
 }
Index: src/main/java/com/wediscussmovies/project/service/GenreService.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/GenreService.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/service/GenreService.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,4 +1,13 @@
 package com.wediscussmovies.project.service;
 
+import com.wediscussmovies.project.model.Genre;
+
+import java.util.List;
+import java.util.Optional;
+
 public interface GenreService {
+    public List<Genre> findAll();
+    public Optional<Genre> findById(Integer id);
+    public List<Genre> findAllByType(String genre);
+    public Genre save(String genreName);
 }
Index: src/main/java/com/wediscussmovies/project/service/MovieService.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/MovieService.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/service/MovieService.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -4,7 +4,11 @@
 
 import java.util.List;
+import java.util.Optional;
 
 public interface MovieService {
     public List<Movie> listAll();
     public List<Movie> searchByTitle(String title);
+    public Optional<Movie> findById(Integer id);
+    public Movie save(Movie movie);
+    public void deleteById(int id);
 }
Index: src/main/java/com/wediscussmovies/project/service/PersonService.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/PersonService.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/service/PersonService.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,4 +1,13 @@
 package com.wediscussmovies.project.service;
 
+import com.wediscussmovies.project.model.Person;
+
+import java.util.List;
+import java.util.Optional;
+
 public interface PersonService {
+    public List<Person> findAllDirectors();
+    public List<Person> findAllActors();
+    Optional<Person> findActorById(Integer id);
+    Optional<Person> findDirectorById(Integer id);
 }
Index: src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
+++ src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -0,0 +1,39 @@
+package com.wediscussmovies.project.service.impl;
+
+import com.wediscussmovies.project.model.Genre;
+import com.wediscussmovies.project.repository.GenreRepository;
+import com.wediscussmovies.project.service.GenreService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+@Service
+public class GenreServiceImpl implements GenreService {
+    private final GenreRepository genreRepository;
+
+    public GenreServiceImpl(GenreRepository genreRepository) {
+        this.genreRepository = genreRepository;
+    }
+
+    @Override
+    public Optional<Genre> findById(Integer id) {
+        return genreRepository.findById(id);
+    }
+
+    @Override
+    public List<Genre> findAllByType(String genre) {
+        return genreRepository.findAllByGenre_typeLike(genre);
+    }
+
+    @Override
+    public Genre save(String genreName) {
+        Genre genre = new Genre(genreName);
+        return genreRepository.save(genre);
+    }
+
+    @Override
+    public List<Genre> findAll() {
+        return genreRepository.findAll();
+    }
+}
Index: src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -7,4 +7,5 @@
 
 import java.util.List;
+import java.util.Optional;
 
 @Service
@@ -22,6 +23,23 @@
 
     @Override
+    public Optional<Movie> findById(Integer id) {
+        return movieRepository.findById(id);
+    }
+
+    @Override
+    public Movie save(Movie movie) {
+        return movieRepository.save(movie);
+    }
+
+    @Override
+    public void deleteById(int id) {
+        movieRepository.deleteById(id);
+    }
+
+    @Override
     public List<Movie> searchByTitle(String title) {
         return movieRepository.findAllByTitleLike("%"+title+"%");
     }
 }
+
+
Index: src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java
===================================================================
--- src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
+++ src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -0,0 +1,40 @@
+package com.wediscussmovies.project.service.impl;
+
+import com.wediscussmovies.project.model.Person;
+import com.wediscussmovies.project.model.PersonType;
+import com.wediscussmovies.project.repository.PersonRepository;
+import com.wediscussmovies.project.service.PersonService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+@Service
+public class PersonServiceImpl implements PersonService {
+    private final PersonRepository personRepository;
+
+    public PersonServiceImpl(PersonRepository personRepository) {
+        this.personRepository = personRepository;
+    }
+
+    @Override
+    public List<Person> findAllDirectors() {
+        return personRepository.findAllByPersonType(PersonType.D);
+    }
+
+    @Override
+    public Optional<Person> findActorById(Integer id) {
+        return personRepository.findPersonByPerson_idAndPersonType(id, PersonType.A);
+    }
+
+
+    @Override
+    public Optional<Person> findDirectorById(Integer id) {
+        return personRepository.findPersonByPerson_idAndPersonType(id, PersonType.D);
+    }
+
+    @Override
+    public List<Person> findAllActors() {
+        return personRepository.findAllByPersonType(PersonType.A);
+    }
+}
Index: src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
===================================================================
--- src/main/java/com/wediscussmovies/project/web/controller/MovieController.java	(revision 6e7b4721e1c9f389c67f55f48aab976c7eb4e7a9)
+++ src/main/java/com/wediscussmovies/project/web/controller/MovieController.java	(revision 7a0bf79dedf74d33b1f9bb8ce17b562e420e1fc6)
@@ -1,13 +1,19 @@
 package com.wediscussmovies.project.web.controller;
 
+import com.wediscussmovies.project.model.Genre;
 import com.wediscussmovies.project.model.Movie;
+import com.wediscussmovies.project.model.Person;
+import com.wediscussmovies.project.model.exception.MovieIdNotFoundException;
+import com.wediscussmovies.project.service.GenreService;
 import com.wediscussmovies.project.service.MovieService;
+import com.wediscussmovies.project.service.PersonService;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
+import org.springframework.web.bind.annotation.*;
+
+import java.sql.Date;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Optional;
 
 @Controller
@@ -15,7 +21,11 @@
 public class MovieController {
     private final MovieService movieService;
-
-    public MovieController(MovieService movieService) {
+    private final GenreService genreService;
+    private final PersonService personService;
+
+    public MovieController(MovieService movieService, GenreService genreService, PersonService personService) {
         this.movieService = movieService;
+        this.genreService = genreService;
+        this.personService = personService;
     }
 
@@ -29,4 +39,7 @@
             movies = movieService.searchByTitle(titleQuery);
         }
+
+        movies.sort(Movie.comparatorTitle);
+
         model.addAttribute("movies", movies);
         model.addAttribute("contentTemplate", "moviesList");
@@ -34,3 +47,178 @@
     }
 
+
+    @GetMapping("/add")
+    public String addMovie(Model model){
+        model.addAttribute("directors", personService.findAllDirectors());
+        model.addAttribute("actors", personService.findAllActors());
+        model.addAttribute("genres", genreService.findAll());
+        model.addAttribute("contentTemplate", "moviesAdd");
+        return "template";
+    }
+
+
+    @PostMapping("/{id}/delete")
+    public String addMovie(@PathVariable int id){
+        Optional<Movie> movie = movieService.findById(id);
+        if(movie.isPresent()){
+            movieService.deleteById(movie.get().getMovie_id());
+        }
+        return "redirect:/movies";
+    }
+
+    @PostMapping("/add/confirm")
+    public String addMoviePost(@RequestParam String title,
+                               @RequestParam String description,
+                               @RequestParam String image_url,
+                               @RequestParam Date airing_date,
+                               @RequestParam Float rating,
+                               @RequestParam Integer director_id,
+                               @RequestParam List<Integer> actors,
+                               @RequestParam List<Integer> genres,
+                               Model model){
+        if(title == null || title.isEmpty() ||
+        description == null || description.isEmpty() ||
+        image_url == null || image_url.isEmpty() ||
+        airing_date == null ||
+        rating == null ||
+        director_id == null ||
+        actors == null || actors.size() == 0 ||
+        genres == null || genres.size() == 0)
+        {
+            model.addAttribute("error", "Not enough attributes, make sure all values are inputted, all of them are required");
+            model.addAttribute("hasError", true);
+            return "redirect:/add";
+        }
+        List<Person> actorsList = new LinkedList<>();
+        for(Integer id: actors){
+            Optional<Person> person = personService.findActorById(id);
+            if(person.isEmpty()){
+                model.addAttribute("error", "The actor with ID {" + id + "} was not found.");
+                model.addAttribute("hasError", true);
+                return "redirect:/add";
+            }
+            actorsList.add(person.get());
+        }
+
+        List<Genre> genreList = new LinkedList<>();
+        for(Integer id: genres){
+            Optional<Genre> genre = genreService.findById(id);
+            if(genre.isEmpty()){
+                model.addAttribute("error", "The genre with ID {" + id + "} was not found.");
+                model.addAttribute("hasError", true);
+                return "redirect:/add";
+            }
+            genreList.add(genre.get());
+        }
+
+        Optional<Person> directorOp = personService.findDirectorById(director_id);
+        if(directorOp.isEmpty()){
+            model.addAttribute("error", "The director with ID {" + director_id + "} was not found.");
+            model.addAttribute("hasError", true);
+            return "redirect:/add";
+        }
+
+        Person director = directorOp.get();
+
+        Movie movie = new Movie(title, description, image_url, airing_date,
+                    rating, director, actorsList, genreList);
+
+        movieService.save(movie);
+
+        return "redirect:/movies";
+    }
+
+    @PostMapping("/edit/confirm")
+    public String editMoviePost(
+                                @RequestParam Integer movie_id,
+                                @RequestParam String title,
+                               @RequestParam String description,
+                               @RequestParam String image_url,
+                               @RequestParam Date airing_date,
+                               @RequestParam Float rating,
+                               @RequestParam Integer director_id,
+                               @RequestParam List<Integer> actors,
+                               @RequestParam List<Integer> genres,
+                               Model model){
+        if(
+                movie_id == null ||
+                title == null || title.isEmpty() ||
+                description == null || description.isEmpty() ||
+                image_url == null || image_url.isEmpty() ||
+                airing_date == null ||
+                rating == null ||
+                director_id == null ||
+                actors == null || actors.size() == 0 ||
+                genres == null || genres.size() == 0)
+        {
+            model.addAttribute("error", "Not enough attributes, make sure all values are inputted, all of them are required");
+            model.addAttribute("hasError", true);
+            return "redirect:/edit";
+        }
+
+        Optional<Movie> movieOptional = movieService.findById(movie_id);
+        if(movieOptional.isEmpty()){
+            model.addAttribute("error", "The movie with ID {" + movie_id + "} was not found.");
+            model.addAttribute("hasError", true);
+            return "redirect:/edit";
+        }
+        Movie movie = movieOptional.get();
+
+        List<Person> actorsList = new LinkedList<>();
+        for(Integer id: actors){
+            Optional<Person> person = personService.findActorById(id);
+            if(person.isEmpty()){
+                model.addAttribute("error", "The actor with ID {" + id + "} was not found.");
+                model.addAttribute("hasError", true);
+                return "redirect:/edit";
+            }
+            actorsList.add(person.get());
+        }
+
+        List<Genre> genreList = new LinkedList<>();
+        for(Integer id: genres){
+            Optional<Genre> genre = genreService.findById(id);
+            if(genre.isEmpty()){
+                model.addAttribute("error", "The genre with ID {" + id + "} was not found.");
+                model.addAttribute("hasError", true);
+                return "redirect:/edit";
+            }
+            genreList.add(genre.get());
+        }
+
+        Optional<Person> directorOp = personService.findDirectorById(director_id);
+        if(directorOp.isEmpty()){
+            model.addAttribute("error", "The director with ID {" + director_id + "} was not found.");
+            model.addAttribute("hasError", true);
+            return "redirect:/edit";
+        }
+
+        Person director = directorOp.get();
+
+        movieService.deleteById(movie_id);
+
+        movie.setActors(actorsList);
+        movie.setDirector(director);
+        movie.setGenres(genreList);
+        movie.setTitle(title);
+        movie.setDescription(description);
+        movie.setAiring_date(airing_date);
+        movie.setImage_url(image_url);
+        movie.setImdb_rating(rating);
+
+        movieService.save(movie);
+
+        return "redirect:/movies";
+    }
+
+    @GetMapping("/{id}/edit")
+    public String editMovie(@PathVariable Integer id, Model model){
+        Movie movie = movieService.findById(id).orElseThrow(() -> new MovieIdNotFoundException(id));
+        model.addAttribute("directors", personService.findAllDirectors());
+        model.addAttribute("actors", personService.findAllActors());
+        model.addAttribute("genres", genreService.findAll());
+        model.addAttribute("movie", movie);
+        model.addAttribute("contentTemplate", "moviesEdit");
+        return "template";
+    }
 }
