public static Movie FindMovieByOwner(this IEntityRepository<Movie> movieRepository, Movie movie, Guid ownerKey)
        {
            var userMovies = movieRepository.FindBy(m => m.UserMovies.Any(u => u.OwnerKey == ownerKey));

            var matches = userMovies.Where(um => um.FileHash == movie.FileHash);

            return matches.FirstOrDefault();
        }
Ejemplo n.º 2
0
        public OperationResult<Movie> AddMovie(Movie movie)
        {
            if(_movieRepository.FindBy(m => m.FileHash == movie.FileHash).Any())
            {
                return new OperationResult<Movie>(false);
            }

            movie.Key = Guid.NewGuid();
            _movieRepository.Add(movie);
            _movieRepository.Save();

            return new OperationResult<Movie>(true) {Entity = movie};
        }
Ejemplo n.º 3
0
        public Movie UpdateMovie(Movie movie)
        {
            _movieRepository.Edit(movie);
            _movieRepository.Save();

            return movie;
        }