Beispiel #1
0
        public async Task Init()
        {
            try
            {
                if (Year == "")
                {
                    Year = "0";
                }
                int.Parse(Year);
            }
            catch
            {
                await Application.Current.MainPage.DisplayAlert("Error",
                                                                "The year must be a number!", "OK");

                return;
            }

            if (MovieGenres.Count == 0)
            {
                MovieGenres.Add(new Genre {
                    GenreID = 0, Name = "None"
                });
                var serviceReturns = await _genreService.Get <List <Genre> >(null);

                foreach (var item in serviceReturns)
                {
                    MovieGenres.Add(item);
                }
            }
            MediaList.Clear();

            int GenreID = 0;

            try
            {
                GenreID = SelectedGenre.GenreID;
            }
            catch
            {
                GenreID = 0;
            }


            MediaSearchRequest request = new MediaSearchRequest
            {
                GenreID = GenreID,
                Title   = MovieTitle,
                Year    = int.Parse(Year)
            };
            string query = await request.ToQueryString();

            var list = await $"{APIService._apiUrl}/MediaSearch?{query}".GetJsonAsync <IEnumerable <Media> >();

            foreach (var item in list)
            {
                if (item.MediaID != 1)
                {
                    MediaList.Add(new ListItem
                    {
                        Id          = item.MediaID,
                        Title       = item.Title,
                        Description = item.Synopsis,
                        Image       = $"{APIService._apiUrl}/images/covers/{item.MediaID}",
                        Rating      = int.Parse(await $"{APIService._apiUrl}/MediaRatings?id={item.MediaID}&username={APIService.Username}".GetStringAsync())
                    });
                }
            }
        }
Beispiel #2
0
 public MovieGenre InsertMovieGenre(MovieGenre movieGenre)
 {
     MovieGenres.Add(movieGenre);
     this.SaveChanges();
     return(movieGenre);
 }