示例#1
0
        public static async Task <List <Vote> > GetVotesByYearOfNominationAndCategory(string yearOfNomination, string category)
        {
            List <Vote> votes = await GetAll();

            List <Nomination> nominations = await NominationAPI.GetNominationsByYearAndCategoryIncludeMovie(yearOfNomination, category);

            List <int> nominationIds = nominations.Select(n => n.Id).ToList();

            votes = votes.Where(v => nominationIds.Contains(v.NominationId)).ToList();
            return(votes);
        }
示例#2
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);
        }
示例#3
0
        public static async Task <List <Vote> > GetByIdentityUserIdYearOfNominationAndCategory(string identityUserId, string yearOfNomination, string category)
        {
            List <Vote> votes = await GetAll();

            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(identityUserId);

            votes = votes.Where(v => v.MoviegoerId == moviegoer.Id).ToList();
            List <Nomination> nominations = await NominationAPI.GetNominationsByYearAndCategoryIncludeMovie(yearOfNomination, category);

            votes = votes.Where(v => nominations.Select(n => n.Id).Contains(v.NominationId)).ToList();
            foreach (Vote vote in votes)
            {
                vote.Nomination = await NominationAPI.GetById(vote.NominationId);
            }
            return(votes);
        }
        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);
            }
        }