Beispiel #1
0
        /*-------------------------------------------------------------------EDIT UPDATE DELETE--------------------------------*/
        public void btnSubmit_Click_one(Object Src, EventArgs E)
        {
            get_connection();
            try
            {
                connection.Open();
                command = new SqlCommand("SELECT * FROM content", connection);
                reader  = command.ExecuteReader();
                MovieResults.DataSource = reader;
                MovieResults.DataBind();

                reader.Close();
            }
            catch (Exception err)
            {
                // Handle an error by displaying the information.
                lblInfo.Text  = "Error reading the database. ";
                lblInfo.Text += err.Message;
            }
            finally
            {
                // Either way, make sure the connection is properly closed.
                // (Even if the connection wasn't opened successfully,
                //  calling Close() won't cause an error.)
                connection.Close();
                lblInfo.Text += "<br /><b>Now Connection Is:</b> ";
                lblInfo.Text += connection.State.ToString();
            }
        }
Beispiel #2
0
        public void btnSubmit_update_record(Object Src, GridViewUpdateEventArgs e)
        {
            get_connection();
            try
            {
                int id = int.Parse(MovieResults.DataKeys[e.RowIndex].Value.ToString());
                connection.Open();

                command = new SqlCommand("UPDATE content SET MovieTitle=@MovieTitle, MovieDescription=@MovieDescription WHERE MovieID=@MovieID", connection);
                command.Parameters.AddWithValue("MovieID", SqlDbType.Int).Value = id;
                command.Parameters.AddWithValue("@MovieTitle",
                                                ((TextBox)MovieResults.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString());
                command.Parameters.AddWithValue("@MovieDescription",
                                                ((TextBox)MovieResults.Rows[e.RowIndex].Cells[3].Controls[0]).Text.ToString());

                command.ExecuteNonQuery();
                MovieResults.DataBind();
            }
            catch (Exception err)
            {
                lblInfo.Text  = "Error reading the database. ";
                lblInfo.Text += err.Message;
            }
            finally
            {
                connection.Close();
                lblInfo.Text += "<br /><b>Update was successfull</b> ";
                lblInfo.Text += connection.State.ToString();
            }
        }
        public async Task <IList <Result> > GetSearchAsync(string query, int pageIndex, int pageSize)
        {
            //Fazendo um GET no serviço

            string sURL = Settings.ApiUrl + "/search/movie?api_key=" + Settings.ApiKey + "&language=" + Settings.Language + "&query=" + query + "&include_adult=false&page=" + pageIndex + "";
            var    uri  = new Uri(string.Format(sURL));

            //Classe para deserializar o retorno
            var resultMovies = new MovieResults();

            try
            {
                var responsepaci = await client.GetAsync(uri);

                //verificando se o status code é OK
                if (responsepaci.IsSuccessStatusCode)
                {
                    //pegando o retorno de lendo em async
                    var content = responsepaci.Content.ReadAsStringAsync().Result;

                    //deserializando o conteudo para a classe result
                    resultMovies = JsonConvert.DeserializeObject <MovieResults>(content);
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            return(resultMovies.results);
        }
Beispiel #4
0
 private void SetMovieData(MovieResults data)
 {
     if (data is not null)
     {
         Results      = data.Results;
         Page         = data.Page;
         TotalPages   = data.Total_Pages;
         TotalResults = data.Total_Results;
     }
 }
        public async Task <MovieResults> getUpcommingMovies(int page)
        {
            moviesRoutes = returnRepositoryConfiguration();

            try
            {
                var result = await moviesRoutes.GetUpcomingMovies(page, Config.Apikey);

                return(result);
            }
            catch (Exception ex)
            {
                var result = new MovieResults();
                result.statusCode    = 500;
                result.statusMessage = $"Aconteceu um erro com a sua solicitação: {ex.Message}";
                return(result);
            }
        }
Beispiel #6
0
        /*-----------------------------------------------------------------SEARCH----------------------------*/
        protected void Search_func(Object src, EventArgs e)
        {
            get_connection();
            connection.Open();
            command = new SqlCommand("SELECT * FROM Content", connection);
            reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                MovieResults.Visible = true;
            }


            MovieResults.DataSource = reader;
            MovieResults.DataBind();

            reader.Close();
        }
Beispiel #7
0
        public async Task <MovieResults> SearchMovies(int page, string query)
        {
            moviesRoutes = returnConfigurationService();

            try
            {
                var result = await moviesRoutes.SearchMovies(page, query, Constantes.Apikey);

                return(result);
            }
            catch (Exception ex)
            {
                var result = new MovieResults();
                result.statusCode    = 500;
                result.statusMessage = $"Aconteceu um erro com a sua solicitação: {ex.Message}";
                return(result);
            }
        }
Beispiel #8
0
    public IEnumerator FindMovie(string urlName, System.Action <MovieData> returnMethod)
    {
        bool looping = true;

        //Wait until the request limit is not reached.
        while (looping)
        {
            if (numCalls >= 40)
            {
                yield return(null);
            }
            else
            {
                numCalls++;
                callsCounting = true;
                break;
            }
        }


        //Request movie data from TMDB
        WWW www = new WWW("https://api.themoviedb.org/3/search/movie?api_key=e2ffb845e5d5fca810eaf5054914f41b&language=en-US&query=" + urlName + "&page=1&include_adult=false", null, headers);

        //Wait for download to finish.
        while (!www.isDone)
        {
            yield return(null);
        }

        //Convert json file to movie data
        var          json    = www.text;
        MovieResults results = JsonConvert.DeserializeObject <MovieResults>(json);

        MovieData[] j = results.results;

        if (j == null)
        {
            Debug.Log("Nothing here");
        }

        returnMethod(j[0]);
    }
Beispiel #9
0
        public void GetLatestMovie()
        {
            var url = "https://api.themoviedb.org/3/movie/upcoming?api_key=" + Config.ApiKey + "&language=en-US";

            var          syncClient = new WebClient();
            string       content    = syncClient.DownloadString(url);
            MovieResults mr         = new MovieResults();

            // Create the Json serializer and parse the movie results response
            mr = JSONHelper.Deserialise <MovieResults>(content);

            var movieData = mr.results.FirstOrDefault();     //to get the first item of the results and parse

            m             = new Movie();
            m.id          = movieData.id;
            m.overview    = movieData.overview;
            m.title       = movieData.title;
            m.poster_path = movieData.poster_path;

            if (MovieDbOps.checkValueExists(movieData.id))
            {
                System.Diagnostics.Debug.WriteLine("Already Posted on Fb");
            }
            else
            {
                MovieDbOps.UploadDbContent(m.id, m.title);
                System.Diagnostics.Debug.WriteLine("Data saved in db");

                var          videoUrl     = "https://api.themoviedb.org/3/movie/" + m.id + "/videos?api_key=" + Config.ApiKey + "&language=en-US";
                string       videoContent = syncClient.DownloadString(videoUrl);
                VideoResults vr           = new VideoResults();

                // Create the Json serializer and parse the videourl response
                vr = JSONHelper.Deserialise <VideoResults>(videoContent);
                var    videoData = vr.results.FirstOrDefault();
                string videoKey  = "https://www.youtube.com/watch?v=" + videoData.key.ToString();

                PostOnFb(m, videoKey);
            }
        }