public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); User loginUser = await _context.User.FirstOrDefaultAsync(u => u.UserName.Equals(username)); Team = await _context.Team.FirstOrDefaultAsync(t => t.UserID.Equals(loginUser.UserId) && t.EventID.Equals(app.EventID)); //That is because we are trying to find the login user current team if he/she has any if (Team == null) { //This is because only leaders can edit team details return(RedirectToPage("MyTeam")); } allThemes = await _context.Theme.Where(t => t.EventID.Equals(app.EventID)).Select( a => new SelectListItem { Value = a.ThemeId.ToString(), Text = a.ThemeName } ).ToListAsync(); return(Page()); }
//No need to check the user status as admin //as only admin will be able to access this page public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username != app.AdminName) { //As only admin should be allowed to make or remove judges return(RedirectToPage("Privacy")); } allThemes = await _context.Theme.Where(t => t.EventID.Equals(app.EventID)).ToArrayAsync(); //We just upload those users who are judges within the current event //Admin does not need to change the judges from previous events Judges = await _context.Judge.Where(j => j.EventID.Equals(app.EventID)).ToListAsync(); Users = await _context.User.ToListAsync(); JudgeStatus = "Make-Judge"; ThemeName = "Non-Judge"; ThemeType = "Non-Judge"; return(Page()); }
public async Task <IActionResult> OnPostAsync() { int fileid = Int32.Parse(Request.Form["fileid"]); string username = HttpContext.Session.GetString("username"); //Firstly we need to find wether the user is a member of a team leader //It is so that we can find his/her team //1. Team leader AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); TeamPresentation teamPresentation = await _context.TeamPresentation.FirstOrDefaultAsync(tp => tp.TeamPresentationId.Equals(fileid) && tp.EventID.Equals(app.EventID)); if (teamPresentation == null) { Message = "There was an error with your uploaded file!!Please upload again"; return(Page()); } else { var path = Path.Combine(Directory.GetCurrentDirectory(), "Files", teamPresentation.FileName); var memory = new MemoryStream(); using (var stream = new FileStream(path, FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; return(File(memory, GetContentType(path), Path.GetFileName(path))); } }
public async Task <IActionResult> OnGetAsync(int?id) { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("/Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } if (id == null) { return(NotFound()); } Event = await _context.Event.FirstOrDefaultAsync(m => m.EventId == id); if (Event == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username != app.AdminName) { return(RedirectToPage("Privacy")); } TieBreakers = await _context.TieBreaker.ToListAsync(); if (TieBreakers.Count() == 0) { //Which shouldn't be the case if admin has come through following the steps return(RedirectToPage("JudgeVotes")); } allEvents = await _context.Event.ToListAsync(); allTeams = await _context.Team.Where(t => t.EventID.Equals(app.EventID)).ToListAsync(); allUsers = await _context.User.ToListAsync(); return(Page()); }
public IActionResult OnGet() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = _context.AppCondition.FirstOrDefault(app => app.AppConditionId.Equals(1)); User loginuser = _context.User.FirstOrDefault(u => u.UserName.Equals(username)); //We need to make sure that he/she is not part of any other team for the current event Team team = _context.Team.FirstOrDefault(t => t.UserID.Equals(loginuser.UserId) && t.EventID.Equals(app.EventID)); if (team != null) { //That would mean he/she already has a team //So we just send him/her to my team page return(RedirectToPage("MyTeam")); } Member member = _context.Member.FirstOrDefault(m => m.UserID.Equals(loginuser.UserId) && m.EventID.Equals(app.EventID)); if (member != null) { //That would mean user has a team //So we send him/her there return(RedirectToPage("MyTeam")); } Users = _context.User.ToList(); Team = _context.Team.Where(t => t.EventID.Equals(app.EventID)).ToList(); return(Page()); }
public static bool MeetCondition(string softwareName, string applicationName, SpecificConfig entity) { bool Apply(Condition condition, Func <bool> isMeet) => condition.Excluding ? !isMeet() : isMeet(); bool CheckConditions(IEnumerable <Condition> conditions, bool isOr) { bool Predicate(Condition c) => c switch { AppCondition app => Apply(c, () => softwareName == app.AppName), InstalledAppCondition installedApp => Apply(c, () => applicationName == installedApp.AppName), AndCondition andCondition => Apply(c, () => CheckConditions(andCondition.Conditions, false)), OrCondition orCondition => Apply(c, () => CheckConditions(orCondition.Conditions, true)), _ => false }; return(isOr ? conditions.OrderBy(c => c.Order).Any(Predicate) : conditions.OrderBy(c => c.Order).All(Predicate)); } return(entity.Conditions.IsEmpty || CheckConditions(entity.Conditions, false)); } }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } eventList = await _context.Event.Select(eve => new SelectListItem { Value = eve.EventCode, Text = eve.EventCode }).ToListAsync(); Team = await _context.Team.ToListAsync(); allEvents = await _context.Event.ToListAsync(); allUsers = await _context.User.ToListAsync(); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(a => a.AppConditionId.Equals(1)); Event eve = await _context.Event.FirstOrDefaultAsync(e => e.EventId.Equals(app.EventID)); if (eve == null) { //Something obviously went wrong //Such as admin might have deleted the event return(RedirectToPage("Privacy")); } Theme.EventID = eve.EventId; Theme.EventCode = eve.EventCode; Theme.EventName = eve.EventName; _context.Theme.Add(Theme); await _context.SaveChangesAsync(); return(RedirectToPage("./Privacy")); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (app.AdminName.Equals(username)) { isAdmin = true; } else { isAdmin = false; } //This is because we don't anyone to see admin details //As it slightly reduce chances of hacking allUsers = await _context.User.Where(u => u.UserId != app.AdminID).ToListAsync(); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } if (!ModelState.IsValid) { EventsList = await _context.Event.ToListAsync(); return(Page()); } _context.Theme.Add(Theme); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); User loginuser = await _context.User.FirstOrDefaultAsync(u => u.UserName.Equals(username)); //This is to make sure user is just trying to remove his current team Member member = await _context.Member.FirstOrDefaultAsync(m => m.UserID.Equals(loginuser.UserId) && m.EventID.Equals(app.EventID)); if (member == null) { //This would mean he doesn't have a team for the current event return(RedirectToPage("MyTeam")); } //That means user does have a team //So we will go forward with the processing Event eve = await _context.Event.FirstOrDefaultAsync(e => e.EventId.Equals(app.EventID)); Team = await _context.Team.FirstOrDefaultAsync(t => t.TeamId.Equals(member.TeamID) && t.EventID.Equals(member.EventID)); User leader = await _context.User.FirstOrDefaultAsync(u => u.UserId.Equals(Team.UserID)); Email = leader.Email; EventCode = eve.EventCode; return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(RedirectToPage("AllTeams")); } string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username != app.AdminName) { return(RedirectToPage("AllTeams")); } Team = await _context.Team.FirstOrDefaultAsync(m => m.TeamId.Equals(id)); if (Team == null) { return(RedirectToPage("AllTeams")); } int themeid = Team.ThemeID; allThemes = await _context.Theme.Where(t => t.EventID.Equals(app.EventID)).Select( a => new SelectListItem { Value = a.ThemeId.ToString(), Text = a.ThemeName } ).ToListAsync(); allUsers = await _context.User.ToListAsync(); UserName = "******"; allUsers = await _context.User.ToListAsync(); IList <Member> allMembers = await _context.Member.Where(m => m.TeamID.Equals(Team.TeamId) && m.EventID.Equals(Team.EventID)).ToListAsync(); totalMembers = allMembers.Count(); TeamPresentation teamPresentation = await _context.TeamPresentation.FirstOrDefaultAsync(tp => tp.TeamID.Equals(Team.TeamId)); allEvents = await _context.Event.ToListAsync(); if (teamPresentation == null) { hasPresentation = false; } else { hasPresentation = true; } return(Page()); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); Team = await _context.Team.Where(t => t.EventID.Equals(app.EventID)).ToListAsync(); IList <User> Users = await _context.User.ToListAsync(); foreach (var team in Team) { //WE will be using Userid as a place to store the total votes for a team team.UserID = 0; } User loginUser = await _context.User.FirstOrDefaultAsync(u => u.UserName.Equals(username)); if (app.AdminName.Equals(username)) { isAdmin = true; } else { isAdmin = false; } foreach (var user in Users) { //Firstly we need to fetch all the vote users has for this session IList <Vote> userVotes = await _context.Vote.Where(v => v.UserID.Equals(user.UserId) && v.EventID.Equals(app.EventID)).ToListAsync(); //Next based on the vote we assign or increment each vote by one based on the respective user votes foreach (var vote in userVotes) { foreach (var team in Team) { if (vote.TeamID.Equals(team.TeamId)) { //That is the user has voted for this team in the event //So we just increament the team vote by one team.UserID += 1; } } } } return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); allUsers = await _context.User.ToListAsync(); allEvents = await _context.Event.ToListAsync(); //Before we go and update the data we need to make sure of certain things //Team Name if unique within the event //We search if there is a team with same name //IList<Team> allTeams = await _context.Team.Where(t => t.EventID.Equals(Team.EventID)).ToListAsync(); Team team1 = await _context.Team.FirstOrDefaultAsync(t => t.UserID.Equals(Team.TeamName) && t.EventID.Equals(app.EventID)); if (team1 != null) { Message = "Team with same name exists!!"; allUsers = await _context.User.ToListAsync(); allEvents = await _context.Event.ToListAsync(); allTeams = await _context.Team.ToListAsync(); Team = await _context.Team.FirstOrDefaultAsync(t => t.TeamId.Equals(Team.TeamId)); return(Page()); } //We prevent the admin from making changes to username, joincode and EventID //The reason being they have a lot of dependency and wrong changes can crash the system //So for now we just leave it and figure out an alternative for that if (ModelState.IsValid) { Team team = await _context.Team.FirstOrDefaultAsync(t => t.TeamId.Equals(Team.TeamId) && t.EventID.Equals(app.EventID)); team.ProjectName = Team.ProjectName; team.Idea = Team.Idea; //We are not going to edit theme here await _context.SaveChangesAsync(); return(RedirectToPage("AllTeams")); } Message = "Something went wrong!! Please try again!!"; return(Page()); }
public IActionResult OnGet() { string username = HttpContext.Session.GetString("username"); AppCondition app = _context.AppCondition.FirstOrDefault(a => a.AppConditionId.Equals(1)); if (username != app.AdminName) { return(RedirectToPage("Privacy")); } return(Page()); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); AppCondition = await _context.AppCondition.FirstOrDefaultAsync(m => m.AppConditionId.Equals(1)); if (username != AppCondition.AdminName) { return(RedirectToPage("Privacy")); } return(Page()); }
public async Task <IActionResult> OnPostAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } eventList = await _context.Event.Select(eve => new SelectListItem { Value = eve.EventCode, Text = eve.EventCode }).ToListAsync(); allEvents = await _context.Event.ToListAsync(); var code = Request.Form["eventid"]; if (code == "All") { Theme = await _context.Theme.ToListAsync(); return(Page()); } Event eve = await _context.Event.FirstOrDefaultAsync(eve => eve.EventCode.Equals(code)); Theme = await _context.Theme.Where(peo => peo.EventID.Equals(eve.EventId)).ToListAsync(); if (Theme == null) { //That is no such team has been stored //Or that event is still going on Message = "No Such team Exist for that event!!"; return(Page()); } else { Message = ("Now displaying themes from event " + eve.EventCode); } return(Page()); }
public async Task <IActionResult> OnPostAsync() { AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); int teamid = Team.TeamId; //To delete a team we need to remove all the member of that team IList <Member> teamMembers = await _context.Member.Where(m => m.TeamID.Equals(teamid) && m.EventID.Equals(app.EventID)).ToListAsync(); foreach (var member in teamMembers) { _context.Member.Remove(member); await _context.SaveChangesAsync(); } //Now that team has been deleted we have to remove votes for that team in the event IList <Vote> teamVotes = await _context.Vote.Where(v => v.TeamID.Equals(Team.TeamId) && v.EventID.Equals(app.EventID)).ToListAsync(); foreach (var vote in teamVotes) { _context.Vote.Remove(vote); await _context.SaveChangesAsync(); } //we also need to remove the presentation of the team if any TeamPresentation teamPresentation = await _context.TeamPresentation.FirstOrDefaultAsync(tp => tp.TeamID.Equals(Team.TeamId)); if (teamPresentation != null) { //We need to remove the file from the folder as well. string storedFile = teamPresentation.FileName; var oldPath = Path.Combine(Directory.GetCurrentDirectory(), "Files", storedFile); if (System.IO.File.Exists(oldPath)) { System.IO.File.Delete(oldPath); _context.TeamPresentation.Remove(teamPresentation); await _context.SaveChangesAsync(); } else { _context.TeamPresentation.Remove(teamPresentation); await _context.SaveChangesAsync(); } } _context.Team.Remove(Team); await _context.SaveChangesAsync(); return(RedirectToPage("./Privacy")); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPagePermanent("Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); Theme = await _context.Theme.Where(th => th.EventID.Equals(app.EventID)).ToListAsync(); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } AppCondition = await _context.AppCondition.FirstOrDefaultAsync(m => m.AppConditionId == id); if (AppCondition == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); User user = _context.User.FirstOrDefault(u => u.UserName.Equals(username)); if (username == null) { return(Page()); } else { if (user == null) { return(RedirectToPage("Index")); } } // User user = _context.User.FirstOrDefault(u => u.UserName.Equals(username)); //Now that everything regarding the user is checked we check if he/she already own a team //Or that he/she is a member of another team with same event AppCondition app = _context.AppCondition.FirstOrDefault(app => app.AppConditionId.Equals(1)); Team team = _context.Team.FirstOrDefault(t => t.UserID.Equals(user.UserId) && t.EventID.Equals(app.EventID)); //Firsly check for the team if (team != null) { //That would means he/she has a team return(RedirectToPage("Privacy")); } allThemes = await _context.Theme.Where(t => t.EventID.Equals(app.EventID)).Select(a => new SelectListItem { Value = a.ThemeId.ToString(), Text = a.ThemeName }).ToListAsync(); Member member = _context.Member.FirstOrDefault(m => m.UserID.Equals(user.UserId) && m.EventID.Equals(app.EventID)); //Now we have to check if he/she is a team member if (member != null) { //That would mean he/she is a team member for the current event return(RedirectToPage("Privacy")); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { //Here id refers to tiebreaker id as due to design flaws if (id == null) { return(RedirectToPage("PeopleWinnerList")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); TieBreaker tie = await _context.TieBreaker.FirstOrDefaultAsync(tie => tie.TieBreakerId.Equals(id) && tie.EventID.Equals(app.EventID)); if (tie == null) { //Something obviosuly went wrong return(RedirectToPage("PeopleVotes")); } Team = await _context.Team.FirstOrDefaultAsync(t => t.TeamId.Equals(tie.TeamID) && t.EventID.Equals(tie.EventID)); if (Team.TeamId != tie.TeamID) { //Which shouldn't be the case considering the OnGet function return(RedirectToPage("PeopleVotes")); } PeopleWinner peopleWinner = new PeopleWinner() { EventID = Team.EventID, TeamID = Team.TeamId, TeamName = Team.TeamName, UserID = Team.UserID }; _context.PeopleWinner.Add(peopleWinner); await _context.SaveChangesAsync(); //Now that winner has been found we need to remove the tie breaker teams IList <TieBreaker> tieBreakers = await _context.TieBreaker.ToListAsync(); foreach (var ties in tieBreakers) { _context.TieBreaker.Remove(ties); await _context.SaveChangesAsync(); } return(RedirectToPage("./PeopleWinnerList")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { // Checking user's logged in role string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("/Privacy")); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } if (!ModelState.IsValid) { EventsList = await _context.Event.ToListAsync(); return(Page()); } _context.Attach(Theme).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThemeExists(Theme.ThemeId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); app.VotesAllowed = AppCondition.VotesAllowed; app.MemberPerTeam = AppCondition.MemberPerTeam; await _context.SaveChangesAsync(); return(RedirectToPage("./Privacy")); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); User user = await _context.User.FirstOrDefaultAsync(u => u.UserName.Equals(username)); Team = await _context.Team.FirstOrDefaultAsync(t => t.UserID.Equals(user.UserId) && t.EventID.Equals(app.EventID)); if (Team == null) { //We just send the user back as only team leader should be allowed to upload presentation return(RedirectToPage("Privacy")); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } AppCondition = await _context.AppCondition.FindAsync(id); if (AppCondition != null) { _context.AppCondition.Remove(AppCondition); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync() { string username = HttpContext.Session.GetString("username"); if (username == null) { return(RedirectToPage("MyTeam")); } //Firstly we need to check wether the user is a leader or nor AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); User loginUser = await _context.User.FirstOrDefaultAsync(u => u.UserName.Equals(username)); Team = await _context.Team.FirstOrDefaultAsync(t => t.UserID.Equals(loginUser.UserId) && t.EventID.Equals(app.EventID)); if (Team == null) { //User is not a leader or team owner return(RedirectToPage("MyTeam")); } User user = await _context.User.FirstOrDefaultAsync(u => u.UserId.Equals(Team.UserID)); Leader = "not-found"; Email = "not-found"; if (user != null) { Leader = user.FullName; Email = user.Email; } Event eve = await _context.Event.FirstOrDefaultAsync(e => e.EventId.Equals(Team.EventID)); EventCode = "Not-found"; EventName = "Not-found"; if (eve != null) { EventCode = eve.EventCode; EventName = eve.EventName; } return(Page()); }
public async Task OnGetAsync() { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (username == app.AdminName) { isAdmin = true; } else { isAdmin = false; } EventsList = await _context.Event.ToListAsync(); }
public async Task <IActionResult> OnGetAsync(int?id) { string username = HttpContext.Session.GetString("username"); AppCondition app = await _context.AppCondition.FirstOrDefaultAsync(app => app.AppConditionId.Equals(1)); if (app.AdminName != username) { //As only admin decide who can be the winner return(RedirectToPage("Privacy")); } if (id == null) { //Which shouldn't be possible if the admin correct path and procedure return(RedirectToPage("TieBreak")); } TieBreaker tie = await _context.TieBreaker.FirstOrDefaultAsync(tie => tie.TieBreakerId.Equals(id) && tie.EventID.Equals(app.EventID)); if (tie == null) { //Which means the tie breaker team is not found return(RedirectToPage("PeopleVotes")); } Event eve = await _context.Event.FirstOrDefaultAsync(eve => eve.EventId.Equals(tie.EventID)); EventCode = eve.EventCode; Team = await _context.Team.FirstOrDefaultAsync(t => t.TeamId.Equals(tie.TeamID) && t.EventID.Equals(tie.EventID)); if (Team == null) { //Which is not possible unless someone deletes the team //In this case we jus send the admin back to the total votes return(RedirectToPage("PeopleVotes")); } User leader = await _context.User.FirstOrDefaultAsync(u => u.UserId.Equals(Team.UserID)); LeaderName = leader.UserName; return(Page()); }