private DisplayNomineeEntry GetNomineeForVoting(int nominationId) { NominationEntry nominationEntry = db.NominationEntries.Find(nominationId); if (nominationEntry == null) { return(null); } Election election = nominationEntry.Position.Election; VotablePosition position = nominationEntry.Position; string currentUsername = User.Identity.GetUserId(); // ReSharper disable once SimplifyLinqExpression if (!election.EligibilityEntries.Any(entry => entry.Username == currentUsername)) { // This student is not eligible for this election return(null); } IDictionary <VotablePosition, PositionDisplayDataForVoting> positionsData = new VotingManager() .PrepareVotingDataFor( currentUsername, election, positions => positions.Where(p => p == position) ); if ( !positionsData.ContainsKey(position) || positionsData[position].Status != PositionDisplayDataForVoting.PositionStatus.CanVote ) { // Student doesn't have access to this position or cannot vote for it or has voted already return(null); } // ReSharper disable once AssignNullToNotNullAttribute return(positionsData[position].NomineeEntries.First(entry => entry.ModelEntry == nominationEntry)); }