Beispiel #1
0
        /// <summary>
        /// Retourne le casting d'un film
        /// </summary>
        /// <param name="id">:l'id du film</param>
        /// <param name="type">indique si il s'agit d'un film u d'une série</param>
        /// <param name="needImage">true si il faut récupérer l'image</param>
        /// <returns>l'objet Json du casting</returns>
        private async Task <CreditJson> GetCasting(int id, TypeFilmEnum type, bool needImage)
        {
            try
            {
                var lien = ConstructeurLien((type == TypeFilmEnum.FILM) ? MovieDbRequeteEnum.DEMANDECASTINGMOVIE : MovieDbRequeteEnum.DEMANDECASTINGTV, id.ToString(), 0);
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync(new Uri(lien));

                    var jsonString = await response.Content.ReadAsStringAsync();

                    var serializer = new DataContractJsonSerializer(typeof(CreditJson));
                    var ms         = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
                    var data       = (CreditJson)serializer.ReadObject(ms);

                    if (needImage)
                    {
                        foreach (var cr in data.crew)
                        {
                            cr.affiche = new BitmapImage(new Uri(AdresseRootPhotoActeur + cr.profile_path));
                        }

                        foreach (var ca in data.cast)
                        {
                            ca.affiche = new BitmapImage(new Uri(AdresseRootPhotoActeur + ca.profile_path));
                        }
                    }
                    return(data);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #2
0
        private void SelectFilm_Click(object sender, ItemClickEventArgs e)
        {
            if (e.ClickedItem is Film)
            {
                App.AppShell.NavigateFrame(typeof(ConsulterFilmView), (Film)e.ClickedItem);
            }

            if (e.ClickedItem is ResultSearchGenJson)
            {
                var          data     = (ResultSearchGenJson)e.ClickedItem;
                TypeFilmEnum typeData = TypeFilmEnum.FILM;
                switch (data.media_type)
                {
                case "movie":
                    typeData = TypeFilmEnum.FILM;
                    break;

                case "tv":
                    typeData = TypeFilmEnum.SERIE;
                    break;

                case "person":
                    typeData = TypeFilmEnum.PERSONNE;
                    break;
                }

                App.AppShell.NavigateFrame(typeof(ConsulterDataInternetView), new SearchDataInternet {
                    Id = data.id, TypeData = typeData
                });
            }
        }