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); }
/// <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); }
public Movies getMovieByRefID(AppSettings appSettings, string refID) { if (appSettings.apiMoviesProviderName == "OMDB") { _Movie = new MovieOmdb(); } movie = _Movie.getMovieByRefID(appSettings, refID); return(movie); }
/// <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) { } }
/// <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); }