Ejemplo n.º 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);
        }
        public static async void SendMovie(string title, int year)
        {
            JObject jObjectMovie = OMDbAPI.GetMovie(title, year);
            string  json         = jObjectMovie.ToString();
            Movie   movie        = JsonConvert.DeserializeObject <Movie>(json);

            if (movie != null && movie.Year != null)
            {
                movie.Year = movie.Year.Substring(0, 4);
                Console.WriteLine(movie.Title + " added");
            }
            //string jsonMovie = JsonConvert.SerializeObject(movie);
            MovieAPI.Create(movie);
        }
Ejemplo n.º 3
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);
        }
        public static void ImportNominations(string filePath)
        {
            List <CSVEntry> lines = CSVReader.ReadCSV(filePath);

            foreach (CSVEntry entry in lines)
            {
                Nomination nomination = new Nomination();
                nomination.Nominee = entry.Entity;
                //if (MovieAPI.GetByTitleSync(entry.Film) != null)
                //{
                nomination.MovieId = MovieAPI.GetByTitleSync(entry.Film).Id;
                //}
                nomination.AwardCategory = entry.Category;
                nomination.IsWinner      = entry.IsWinner;
                nomination.Year          = entry.Year.ToString();
                NominationAPI.CreateSync(nomination);
            }
        }