//Speichert die Filme in die Datenbank
        public async void SaveData(List <OmbiMovieListModel> ombiMovieListModels)
        {
            // prüfen ob der Film bereits in der DB ist..... Speichern des Movies
            foreach (OmbiMovieListModel m in ombiMovieListModels.Where(n => n.available == false))
            {
                CustomMovie _customMovie = _db.CustomMovie.Where(a => a.MovieDbId == m.theMovieDbId).FirstOrDefault();
                if (_customMovie == null)
                {
                    ApiQueryResponse <Movie> findMovie = await searchMoviefromTheMovieDB(m.theMovieDbId);

                    _db.Add(new CustomMovie {
                        OriginalTitle = findMovie.Item.OriginalTitle, PosterPath = "http://image.tmdb.org/t/p/w185/" + findMovie.Item.PosterPath, Overview = findMovie.Item.Overview, Rating = findMovie.Item.VoteAverage, MovieDbId = findMovie.Item.Id, Releasenames = GetText(findMovie.Item.Title), Title = findMovie.Item.Title
                    });
                    _db.SaveChanges();
                }
            }
            // Filme die bereits vorhanden sind aus DB löschen
            foreach (OmbiMovieListModel m in ombiMovieListModels.Where(n => n.available == true))
            {
                CustomMovie _customMovie = _db.CustomMovie.Where(a => a.MovieDbId == m.theMovieDbId).FirstOrDefault();
                if (_customMovie != null)
                {
                    //Nach den Releasenamensuchen und wenn vorhanden auch löschen
                    Releasenames[] _releasenames = _db.Releasenames.Where(r => r.MovieId == _customMovie.Id).ToArray();
                    if (_releasenames != null)
                    {
                        _db.Releasenames.RemoveRange(_releasenames);
                    }

                    _db.CustomMovie.Remove(_customMovie);
                    _db.SaveChanges();
                }
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutMovie(int id, Movie movie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != movie.Id)
            {
                return(BadRequest());
            }

            db.Entry(movie).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Title,Category")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movie));
        }
        public void SearchMoviewithRegex()
        {
            CustomMovie[] ombiMovie = _db.CustomMovie.Include(x => x.Releasenames).ToArray();

            foreach (CustomMovie item in ombiMovie)
            {
                //** Sebi wars

                var regExList = item.Releasenames.Select(rn => rn.Name).ToArray();

                var releaseMatches = _db.FtpRelease
                                     .Where(r =>
                                            r.MovieId == null &&
                                            RexExTest(r.FtpReleasename, regExList))
                                     .ToArray();


                foreach (var releaseMatch in releaseMatches)
                {
                    releaseMatch.MovieId = item.Id;
                }

                _db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Truncate tables in order to insert new data
        /// </summary>
        /// <param name="db">Local database context</param>
        private void _truncateTables(MovieDatabaseContext db)
        {
            db.Database.ExecuteSqlCommand("DELETE FROM MovieGenres");
            db.SaveChanges();
            db.Database.ExecuteSqlCommand("DELETE FROM Movies");
            db.SaveChanges();
            db.Database.ExecuteSqlCommand("DELETE FROM Genres");
            db.SaveChanges();

            var moviesCount      = db.Movies.Count();
            var genresCount      = db.Genres.Count();
            var movieGenresCount = db.MovieGenres.Count();

            System.Diagnostics.Debug.WriteLine("moviesCount", moviesCount);
            System.Diagnostics.Debug.WriteLine("genresCount", genresCount);
            System.Diagnostics.Debug.WriteLine("movieGenresCount", movieGenresCount);
        }
        public void GetFtpReleases()
        {
            //Konfig FTP Folder parsen
            //var ftpConfig = FtpConfiguration.Value;
            string[] sArray = FtpConfiguration.Value.Folders.Split(';');


            log.Info("Task: Lade FTP Konfig");
            Rebex.Licensing.Key = "==AOptXWwcjeC/mE+S0K60UcnUhOW7heBDBmgjFhBdpuvU==";
            try
            {
                using (var client = new Rebex.Net.Ftp())
                {
                    client.Settings.SslAcceptAllCertificates = true;
                    // connect and log in
                    client.Connect(FtpConfiguration.Value.Host, FtpConfiguration.Value.Port);
                    //if ssl true
                    if (FtpConfiguration.Value.Ssl == true)
                    {
                        client.Secure();
                    }
                    //FTP Login
                    log.Info("Task: FTP Login");
                    client.Login(FtpConfiguration.Value.Username, FtpConfiguration.Value.Passwort);
                    //FTP Root Login
                    client.ChangeDirectory("/");

                    //FTP Ordner durchsuchen
                    log.Info("Task: FTP Ordner durchsuchen");
                    foreach (string s in sArray)
                    {
                        string[] dataItems = client.GetNameList(s);

                        foreach (string a in dataItems)
                        {
                            string relname  = a.Substring(a.LastIndexOf("/") + 1);
                            string relgroup = a.Substring(a.LastIndexOf("-") + 1);

                            FtpRelease _ftpRelease = _db.FtpRelease.Where(r => r.FtpReleasename == relname).FirstOrDefault();

                            if (_ftpRelease == null)
                            {
                                _db.Add(new FtpRelease {
                                    FtpReleasename = relname, FtpReleaseGroup = relgroup, FtpFolder = a
                                });
                                _db.SaveChanges();
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                log.Info("Task: Fehler" + ex);
            }
        }
Ejemplo n.º 7
0
        public void AddMovieScore(int userId, int movieId, int scoreValue)
        {
            var score = new Score {
                MovieId = movieId, UserId = userId, ScoreValue = scoreValue
            };

            _context.Scores.Add(score);

            _context.SaveChanges();
        }
Ejemplo n.º 8
0
        public void AddMovie(Movie movie)
        {
            _context.Movies.Add(movie);

            _context.SaveChanges();
        }
        public void AddFavorite(Favorite newFavorite)
        {
            _context.Favorites.Add(newFavorite);

            _context.SaveChanges();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Insert new movies data
 /// </summary>
 /// <param name="db">Local database context</param>
 /// <param name="movies">Movies collection to be inserted</param>
 private void _insertMovies(MovieDatabaseContext db, IEnumerable <Movie> movies)
 {
     db.Movies.AddRange(movies);
     db.SaveChanges();
 }
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }
        public void AddUser(User user)
        {
            _context.Users.Add(user);

            _context.SaveChanges();
        }
        public void AddWatched(WatchedMovie newWatchedMovie)
        {
            _context.WatchedMovies.Add(newWatchedMovie);

            _context.SaveChanges();
        }
        public void AddReview(Review newReview)
        {
            _context.Reviews.Add(newReview);

            _context.SaveChanges();
        }