private IMDb getImdb(string i_NameToSearch) { IMDb theMovie = new IMDb(); IMDb theMovie2 = null; try { string imdbUrl = theMovie.getIMDbUrl(System.Uri.EscapeUriString(i_NameToSearch)); int indexOfId = imdbUrl.LastIndexOf("tt"); string IdNameOfMovie = imdbUrl.Substring(indexOfId, imdbUrl.Length - indexOfId - 1); foreach (IMDb currentImdb in List) { if (currentImdb.Id == IdNameOfMovie) { theMovie2 = currentImdb; break; } } } catch(Exception exceptionFindingTheMovie) { m_XmlException.ExceptionOccurred(exceptionFindingTheMovie); theMovie = null; } return theMovie2; }
private void saveToFileCache(IMDb i_Movie) { ReadFromFile(); if (searchResualt == null) { searchResualt = new List<IMDb>(); } searchResualt.Add(i_Movie); SaveAndReadXmlFile.SaveToXml(c_FileName, searchResualt, FileMode.Create); }
public bool Search(string i_NameToSearch, out IMDb io_TheMovie) { bool movieExistAlready = false; ReadFromFile(); io_TheMovie = getImdb(i_NameToSearch); if(io_TheMovie != null) { movieExistAlready = true; } return movieExistAlready; }
public bool Search(string i_NameOfTheMovie, out IMDb io_TheMovie) { io_TheMovie = null; bool movieExist = false; IMDb searchMovie = new IMDb(i_NameOfTheMovie); io_TheMovie = searchMovie; saveToFileCache(searchMovie); if(searchMovie != null) { movieExist = true; } return movieExist; }