Beispiel #1
0
        public ActionResult GetSerie(int id)
        {
            {
                HttpWebRequest apiRequest  = WebRequest.Create("https://api.themoviedb.org/3/tv/" + id + "?api_key=" + apiKey + "&language=es-MX") as HttpWebRequest;
                string         apiResponse = "";
                using (HttpWebResponse response = apiRequest.GetResponse() as HttpWebResponse)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream());
                    apiResponse = reader.ReadToEnd();
                }

                ResponseSerie    rootObject       = JsonConvert.DeserializeObject <ResponseSerie>(apiResponse);
                TheMovieDbSeries theMovieDbSeries = new TheMovieDbSeries();
                theMovieDbSeries.name        = rootObject.name;
                theMovieDbSeries.overview    = rootObject.overview;
                theMovieDbSeries.poster_path = rootObject.poster_path == null?Url.Content("~/Content/Image/no-image.png") : "https://image.tmdb.org/t/p/w500/" + rootObject.poster_path;

                theMovieDbSeries.id = rootObject.id;
                theMovieDbSeries.number_of_seasons   = rootObject.number_of_seasons;
                theMovieDbSeries.last_air_date       = rootObject.last_air_date;
                theMovieDbSeries.next_episode_to_air = rootObject.next_episode_to_air == null ? "" : rootObject.next_episode_to_air.ToString().Substring(18, 10);
                theMovieDbSeries.status = rootObject.status;

                return(View(theMovieDbSeries));
            }
        }
Beispiel #2
0
        private void updateSeries()
        {
            string valorParametro = "U";
            var    parametro      = new SqlParameter("@parametro", valorParametro);
            var    listaIDSerie   = db.Database.SqlQuery <CatSerie>("seriesDia @parametro", parametro).ToList();

            foreach (var item in listaIDSerie)
            {
                int    id = item.IDSerie;
                string estado = "";
                string ultimoEpisodio, proximoEpisodio;

                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3
                                                        | SecurityProtocolType.Tls
                                                        | SecurityProtocolType.Tls11
                                                        | SecurityProtocolType.Tls12;

                HttpWebRequest apiRequest  = WebRequest.Create("https://api.themoviedb.org/3/tv/" + id + "?api_key=" + apiKey + "&language=es-MX") as HttpWebRequest;
                string         apiResponse = "";

                using (HttpWebResponse response = apiRequest.GetResponse() as HttpWebResponse)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream());
                    apiResponse = reader.ReadToEnd();
                }

                ResponseSerie rootObject = JsonConvert.DeserializeObject <ResponseSerie>(apiResponse);
                estado          = rootObject.status;
                ultimoEpisodio  = rootObject.last_air_date;
                proximoEpisodio = rootObject.next_episode_to_air == null ? "0001-01-01" : rootObject.next_episode_to_air.ToString().Substring(18, 10);

                try
                {
                    db.actualizarFechaSeries(id, estado, Convert.ToDateTime(ultimoEpisodio), Convert.ToDateTime(proximoEpisodio));
                }
                catch (Exception ex)
                {
                    View("Error", new HandleErrorInfo(ex, "Home", "Index"));
                }
            }
        }