public static bool AddCandidate(string candidateName, string seatName, string teamName) { List <Seats> lSeat = DatabaseHandler.GetAllSeats(); List <Teams> lTeam = DatabaseHandler.GetAllTeams(); List <Candidates> lCan = DatabaseHandler.GetAllCandidates(); int seatId = 0; int teamId = 0; foreach (Seats seat in lSeat) { if (seat.SeatName == seatName) { seatId = seat.SeatId; break; } } foreach (Teams team in lTeam) { if (team.TeamName == teamName) { teamId = team.TeamId; break; } } foreach (Candidates can in lCan) { if (can.SeatId == seatId && can.TeamId == teamId) { return(false); } } DatabaseHandler.AddCandidate(candidateName, seatId, teamId); return(true); }