Пример #1
0
 //MONGO TO INTERNAL
 public InternalMovie Movie(MongoMovie mongoMovie)
 {
     return(new InternalMovie
     {
         Title = mongoMovie.Title,
         Adult = mongoMovie.Adult,
         BackdropPath = mongoMovie.BackdropPath,
         BelongsToCollection = Collection(mongoMovie.BelongsToCollection),
         Budget = mongoMovie.Budget,
         Genres = Genre(mongoMovie.Genres),
         Homepage = mongoMovie.Homepage,
         TmdbId = mongoMovie.TmdbId,
         ImdbId = mongoMovie.ImdbId,
         OriginalLanguage = mongoMovie.OriginalLanguage,
         OriginalTitle = mongoMovie.OriginalTitle,
         Overview = mongoMovie.Overview,
         Popularity = mongoMovie.Popularity,
         PosterPath = mongoMovie.PosterPath,
         ProductionCompanies = ProdCompanies(mongoMovie.ProductionCompanies),
         ProductionCountries = ProdCountries(mongoMovie.ProductionCountries),
         ReleaseDate = mongoMovie.ReleaseDate,
         Revenue = mongoMovie.Revenue,
         Runtime = mongoMovie.Runtime,
         SpokenLanguages = SpokenLanguages(mongoMovie.SpokenLanguages),
         Status = mongoMovie.Status,
         Tagline = mongoMovie.Tagline,
         VoteAverage = mongoMovie.VoteAverage,
         VoteCount = mongoMovie.VoteCount
     });
 }
Пример #2
0
        public async Task <bool> IsMovieStarted(int userid, MongoMovie mongoMovie)
        {
            var isItStarted =
                await StartedMovies.CountDocumentsAsync(
                    movie => movie.ImdbId == mongoMovie.ImdbId || movie.TmdbId == mongoMovie.TmdbId);

            return(isItStarted > 0);
        }
Пример #3
0
        public async Task <bool> IsMovieSeen(MongoMovie mongoMovie, int userid)
        {
            var result = await SeenMovies.FindAsynchronous(
                movie => (movie.TmdbId == mongoMovie.TmdbId ||
                          movie.ImdbId == mongoMovie.ImdbId) && movie.UserId == userid);

            return(result.Count == 1);
        }
Пример #4
0
        public async Task <bool> CheckIfMovieExistInMongo(MongoMovie mongoMovie)
        {
            var res = await Movies.FindAsynchronous(movie => movie.Title == mongoMovie.Title);

            if (res.Count > 0)
            {
                return(true);
            }

            return(false);
        }
Пример #5
0
        public async Task <bool> MarkAsSeenMovie(MongoMovie mongoMovie, int userid)
        {
            await SeenMovies.InsertOneAsync(new SeenMovie
            {
                UserId = userid,
                ImdbId = mongoMovie.ImdbId,
                TmdbId = mongoMovie.TmdbId,
                Date   = DateTime.Now
            });

            return(true);
        }
Пример #6
0
        public async Task <bool> IsMovieSeen(InternalMovieSeenRequest model)
        {
            var movieIfExist = await _repo.GetMovieByTitle(model.Title);

            if (movieIfExist != null)
            {
                var movie = new MongoMovie
                {
                    TmdbId = movieIfExist.TmdbId,
                    ImdbId = movieIfExist.ImdbId
                };
                var result = await _repo.IsMovieSeen(movie, model.UserId);

                return(result);
            }
            throw new InternalException(650, "Movie not found");
        }
Пример #7
0
 public async Task Import(MongoMovie mongoMovie)
 {
     await Movies.InsertOneAsync(mongoMovie);
 }