示例#1
0
        public static async Task <List <Nomination> > GetNominationsByYearAndCategoryIncludeMovie(string year, string category)
        {
            List <Nomination> allNominations = await NominationAPI.GetAll();

            List <Nomination> nominations = allNominations.Where(n => n.Year == year && n.AwardCategory == category).ToList();

            foreach (Nomination nomination in nominations)
            {
                nomination.Movie = await MovieAPI.GetById(nomination.MovieId);
            }
            return(nominations);
        }
示例#2
0
        public static async Task <Nomination> GetById(int id)
        {
            Nomination nomination = new Nomination();

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync("https://localhost:44366/api/Nominations/" + id);

                string data = await response.Content.ReadAsStringAsync();

                nomination = JsonConvert.DeserializeObject <Nomination>(data);
            }
            nomination.Movie = await MovieAPI.GetById(nomination.MovieId);

            return(nomination);
        }