Ejemplo n.º 1
0
        public async Task <ActionResult> DisplayNominations(string year, string category)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("DisplayNominations", "Home", new YearCategoryModel(year, category)));
            }
            string    userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(userId);

            List <Vote> myVotes = await VoteAPI.GetByIdentityUserIdYearOfNominationAndCategory(userId, year, category);

            bool hasVotedThisYear = myVotes.Where(v => v.Date.Year == DateTime.Now.Year).FirstOrDefault() != null;

            if (!hasVotedThisYear)
            {
                return(RedirectToAction(nameof(VoteOnNomination), new YearCategoryModel(year, category)));
            }
            NominationViewModel nominationViewModel = await CreateNominationViewModel(year, category);

            nominationViewModel.JsonVotes        = JsonDataBuilder.CreateJsonVoteCollection(nominationViewModel);
            nominationViewModel.JsonNomineeNames = JsonDataBuilder.CreateJsonStringFromStringList(nominationViewModel.Nominations.Select(n => n.Nominee).ToList());
            nominationViewModel.MyVotes          = await VoteAPI.GetByIdentityUserIdYearOfNominationAndCategory(userId, year, category);

            nominationViewModel.AllYearCategoryCombinations = await NominationAPI.GetAllYearCategoryCombinations();

            return(View(nominationViewModel));
        }
        public async Task <ActionResult> DisplayNominations(string year, string category)
        {
            NominationViewModel nominationViewModel = await CreateNominationViewModel(year, category);

            nominationViewModel.JsonVotes                   = JsonDataBuilder.CreateJsonVoteCollection(nominationViewModel);
            nominationViewModel.JsonNomineeNames            = JsonDataBuilder.CreateJsonStringFromStringList(nominationViewModel.Nominations.Select(n => n.Nominee).ToList());
            nominationViewModel.AllYearCategoryCombinations = await NominationAPI.GetAllYearCategoryCombinations();

            return(View(nominationViewModel));
        }