Skip to content

Commit

Permalink
feat : Service, Repository CreateMovie 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
SAgiKPJH committed Apr 11, 2024
1 parent 98bda99 commit f92cd43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Clean Architecture/CleanMovie.Application/MovieService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public MovieService(IMovieRepository movieRepository)

public Movie CreateMovie(Movie movie)
{
throw new NotImplementedException();
_movieRepository.CreateMovie(movie);
return movie;
}

public List<Movie> GetAllMovies()
Expand Down
13 changes: 11 additions & 2 deletions Clean Architecture/CleanMovie.Infrastructure/MovieRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ public class MovieRepository : IMovieRepository
new Movie { Id = 2, Name = "Home Alone 4", Cost = 3 }
};

private readonly MovieDBContext _movieDBContext;

public MovieRepository(MovieDBContext movieDBContext)
{
_movieDBContext = movieDBContext;
}

public Movie CreateMovie(Movie movie)
{
throw new NotImplementedException();
_movieDBContext.Movies.Add(movie);
_movieDBContext.SaveChanges();
return movie;
}

public List<Movie> GetAllMovies()
{
return movies;
return _movieDBContext.Movies.ToList();
}
}
}

0 comments on commit f92cd43

Please sign in to comment.