Esempio n. 1
0
 // /////////////// MANAGE COMPETITIONS //////////////////////////////////////// //
 public IActionResult ShowCompetition(int compId)
 {
     if (CheckUser() && (int)HttpContext.Session.GetInt32("AccessLevel") == 9)
     {
         Competition c = _compFactory.GetCompetitionWinners(compId);
         return(View(c));
     }
     else
     {
         return(View("Index", "Home"));
     }
 }
Esempio n. 2
0
        public IActionResult ViewCompetition(int compId)
        {
            if (CheckUser())
            {
                Competition c = _compFactory.GetCompetition(compId);
                //page displaying competition details, including teams and players
                //allowing 5 minutes per presentation
                if (c.End.AddMinutes(c.Teams.Count * 5) > DateTime.Now)
                {
                    ViewBag.message = "Voting will begin after presentations...";
                    return(View("ShowCompetition", c));
                }

                if (c.End.AddDays(1) < DateTime.Now)
                {
                    Competition cWithWinners = _compFactory.GetCompetitionWinners(compId);
                    // cWithWinners.Teams.OrderByDescending(t => t.VotesScored);
                    ViewBag.message = "FINAL RESULTS";
                    return(View("ShowCompetition", cWithWinners));
                }

                //viewing for voting
                StudentCompetitionVote hasVoted = _compFactory.GetVote((int)HttpContext.Session.GetInt32("UserId"), compId);
                if (hasVoted == null)
                {
                    ViewBag.userTeamId = _compFactory.GetStudentTeamId((int)HttpContext.Session.GetInt32("UserId"), compId);
                    return(View("Vote", c));
                }
                else
                {
                    ViewBag.message = "Your vote is in!";
                    return(View("ShowCompetition", c));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }