//Dit mag eigenlijk weg public bool setTeamTrace(Locatie newTrace, int id, string teamNaam) { //id is de gamecode Game game = context.Games.Include(r => r.Teams).ThenInclude(y => y.TeamTraces).Where(d => d.GameCode == id).Single <Game>(); Team team = game.Teams.Where(d => d.TeamNaam == teamNaam).Single <Team>(); List <TeamTrace> traces = team.TeamTraces; if (team == null) { //Geen team return(false); } else { //trace punt toevoegen bij dit team var newtrace = new TeamTrace(); newtrace.trace = newTrace; traces.Add(newtrace); context.SaveChanges(); return(true); } }
public Team SaveCurrentTeamLoc(int id, string teamname, Locatie currentLoc) { //id is de gamecode //we gaan het team selecteren volgens de teamnaam Game game = context.Games.Where(r => r.GameCode == id).Include(r => r.Teams).ThenInclude(y => y.TeamTraces).Single <Game>(); Team team = game.Teams.Where(d => d.TeamNaam == teamname).Single <Team>(); List <TeamTrace> traces = team.TeamTraces; if (team == null) { return(null); } else { //huidige locatie opslaan team.huidigeLocatie = currentLoc; //nieuwe trace toevoegen var trace = new TeamTrace(); trace.trace = currentLoc; if (traces == null) { //nog geen trace aanwezig traces = new List <TeamTrace>(); traces.Add(trace); } else { traces.Add(trace); } context.SaveChanges(); return(team); } }