示例#1
0
        public Movies getMovieByRefID(AppSettings appSettings, string refID)
        {
            DTO.Movies movie = null;

            try
            {
                string url = "http://www.omdbapi.com/?i=" + refID + "&apikey=31aaac41";

                Helper hp       = new Helper();
                string jsonData = hp.urlGetResponse(url);

                if (!jsonData.Contains("Movie not found!"))
                {
                    movie = JsonConvert.DeserializeObject <DTO.Movies>(jsonData.Replace("imdbID", "refID").Replace("imdbRating", "Rating").Replace("imdbVotes", "Votes"));
                }
            }
            catch (Exception ex)
            {
                LogManagement.ILogger logger = new LogManagement.Logger();
                logger.add(appSettings.logConfigFile, "Error:" + ex.InnerException);
            }


            return(movie);
        }
示例#2
0
 /// <summary>
 /// appSetting den gelen ProviderName aracılığı ile hangi apinin kullanılacağını belirliyoruz.
 /// Böylelikle (Loosely Coupled) bir yapı oluşturulmuş oluyor.
 /// </summary>
 public Movies getMovie(DTO.AppSettings appSettings, string Title)
 {
     if (appSettings.apiMoviesProviderName == "OMDB")
     {
         _Movie = new MovieOmdb();
     }
     movie = _Movie.getMovie(appSettings, Title);
     return(movie);
 }
示例#3
0
 public Movies getMovieByRefID(AppSettings appSettings, string refID)
 {
     if (appSettings.apiMoviesProviderName == "OMDB")
     {
         _Movie = new MovieOmdb();
     }
     movie = _Movie.getMovieByRefID(appSettings, refID);
     return(movie);
 }
示例#4
0
        /// <summary>
        /// Gelen talep doğrultusunda veritabanındaki Filmler listeye alınıyor.
        /// Listeye alınan filmlerin güncel bilgileri APIMovies den gelen bilgiler ile güncelleniyor.
        /// </summary>
        public void updateAllMoviesFromApi()
        {
            try
            {
                List <DAO.Movies> listMovies = (from a in _appSettings.dbContext.Movies
                                                where a.IsDeleted == false
                                                select a).ToList();

                APIMovies.IMovie apiMovie = new APIMovies.Movie();

                foreach (var item in listMovies)
                {
                    try
                    {
                        DTO.Movies dtoMovie = apiMovie.getMovieByRefID(_appSettings, item.refID);

                        item.Title          = dtoMovie.Title;
                        item.Year           = dtoMovie.Year;
                        item.Rated          = dtoMovie.Rated;
                        item.Rating         = dtoMovie.Rating;
                        item.Votes          = dtoMovie.Votes;
                        item.Released       = dtoMovie.Released;
                        item.Runtime        = dtoMovie.Runtime;
                        item.Director       = dtoMovie.Director;
                        item.Writer         = dtoMovie.Writer;
                        item.Actors         = dtoMovie.Actors;
                        item.Plot           = dtoMovie.Plot;
                        item.Language       = dtoMovie.Language;
                        item.Country        = dtoMovie.Country;
                        item.Awards         = dtoMovie.Awards;
                        item.Poster         = dtoMovie.Poster;
                        item.LastUpdateTime = DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        _logger.add(_appSettings.logConfigFile, "Error:" + ex.InnerException);
                    }
                }
                _appSettings.dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
示例#5
0
 /// <summary>
 /// Dışarıdan alınan Title parametresini direk olarak BUS katmanına gönderiyor.
 /// </summary>
 private DTO.Movies getMovie(string Title)
 {
     BUS.Movies busMovies = new BUS.Movies(appSettings);
     DTO.Movies movie     = busMovies.getMovie(Title);
     return(movie);
 }