Ejemplo n.º 1
0
        public void AddMovie(OmdbMovie omdbMovie, string rating)
        {
            string sImdbRating = omdbMovie.imdbRating.Replace(",", ".");
            string sRating     = rating.Replace(",", ".");

            string sWriters = omdbMovie.Plot.Replace("'", "`");

            sWriters = sWriters.Replace("&quot", "");

            string sPlot = omdbMovie.Plot.Replace("'", "`");

            sPlot = sPlot.Replace("&quot", "");
            Console.WriteLine(rating);
            string sSqlConnectionString = "Data Source=193.198.57.183; Initial Catalog = DotNet; User ID = vjezbe; Password = vjezbe";

            using (DbConnection oConnection = new SqlConnection(sSqlConnectionString))
                using (DbCommand oCommand = oConnection.CreateCommand())
                {
                    var query = "INSERT INTO Omdb_Filmovi (Title, Year, Rated, Released, Runtime, Genre, Director, Writer, Actors, Plot, Language, Country, Awards, Poster, Metascore, imdbRating, imdbVotes, imdbID, Type, DVD, BoxOffice, Production, Website, Response, Rating) VALUES ('" + omdbMovie.Title + "', '" + omdbMovie.Year + "', '" + omdbMovie.Rated + "', '" + omdbMovie.Released + "', '" + omdbMovie.Runtime + "', '" + omdbMovie.Genre + "', '" + omdbMovie.Director + "', '" + sWriters + "', '" + omdbMovie.Actors + "', '" + sPlot + "', '" + omdbMovie.Language + "', '" + omdbMovie.Country + "', '" + omdbMovie.Awards + "', '" + omdbMovie.Poster + "', '" + omdbMovie.Metascore + "', '" + sImdbRating + "', '" + omdbMovie.imdbVotes + "', '" + omdbMovie.imdbID + "', '" + omdbMovie.Type + "', '" + omdbMovie.DVD + "', '" + omdbMovie.BoxOffice + "', '" + omdbMovie.Production + "', '" + omdbMovie.Website + "', '" + omdbMovie.Response + "', '" + sRating + "')";

                    //Console.WriteLine(query);
                    oCommand.CommandText = query;
                    oConnection.Open();
                    using (DbDataReader reader = oCommand.ExecuteReader())
                    {
                        reader.Read();
                    }
                }
        }
Ejemplo n.º 2
0
        //vraca listu objekata klase omdb
        public OmdbMovie SearchOmdbMovie(string searchMovie, string searchYear)
        {
            string url  = KreiranjeUrl(searchMovie, searchYear);
            string json = CallRestMethod(url);

            OmdbMovie _omdbMovie = JsonConvert.DeserializeObject <OmdbMovie>(json);

            /*
             *  JObject jsonObject = JObject.Parse(json);
             *  var title = jsonObject["Title"];
             */
            //foreach (JObject item in jsonObject)
            //{
            new OmdbMovie
            {
                Title      = (string)_omdbMovie.Title,
                Year       = (int)_omdbMovie.Year,
                Rated      = (string)_omdbMovie.Rated,
                Released   = (string)_omdbMovie.Released,
                Runtime    = (string)_omdbMovie.Runtime,
                Genre      = (string)_omdbMovie.Genre,
                Director   = (string)_omdbMovie.Director,
                Writer     = (string)_omdbMovie.Writer,
                Actors     = (string)_omdbMovie.Actors,
                Plot       = (string)_omdbMovie.Plot,
                Language   = (string)_omdbMovie.Language,
                Country    = (string)_omdbMovie.Country,
                Awards     = (string)_omdbMovie.Awards,
                Poster     = (string)_omdbMovie.Poster,
                Metascore  = (int)_omdbMovie.Metascore,
                imdbRating = (string)_omdbMovie.imdbRating,
                imdbVotes  = (float)_omdbMovie.imdbVotes,
                imdbID     = (string)_omdbMovie.imdbID,
                Type       = (string)_omdbMovie.Type,
                DVD        = (string)_omdbMovie.DVD,
                BoxOffice  = (string)_omdbMovie.BoxOffice,
                Production = (string)_omdbMovie.Production,
                Website    = (string)_omdbMovie.Website,
                Response   = (string)_omdbMovie.Response
            };
            //}
            return(_omdbMovie);
        }