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));
        }
Ejemplo n.º 2
0
        // GET: Cinephile/Edit/5
        public async Task <ActionResult> Edit()
        {
            string    userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(userId);

            return(View(moviegoer));
        }
Ejemplo n.º 3
0
        // GET: Cinephile
        public async Task <ActionResult> Index()
        {
            string    userId    = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(userId);

            if (moviegoer == null)
            {
                return(RedirectToAction(nameof(CreateMoviegoer)));
            }
            return(View(moviegoer));
        }
Ejemplo n.º 4
0
        private async Task <Vote> CreateNewVote(string userId)
        {
            Moviegoer moviegoer = await MoviegoerAPI.GetByUserId(userId);

            Vote vote = new Vote()
            {
                MoviegoerId = moviegoer.Id,
                Moviegoer   = moviegoer
            };

            return(vote);
        }