public static long AddTeam(Team team) { using (var context = new StffContext()) { var newRow = context.Team.AddTeamRow(team.Name, team.Colors, team.AwayColors, team.ExternalId); //context.Team.Rows.Add(newRow); context.AcceptChanges(); TeamTableAdapter adapter = new TeamTableAdapter(); adapter.Update(context); context.AcceptChanges(); return(newRow.Id); } }
public static long AddMatch(Match match) { using (var context = new StffContext()) { var homeTeamRow = GetTeamRow(match.HomeTeam, context); var awayTeamRow = GetTeamRow(match.AwayTeam, context); var referee = GetRefereeRow(match.Ref.ExternalId, context); var assRef1 = GetRefereeRow(match.Ref.ExternalId, context); var assRef2 = GetRefereeRow(match.Ref.ExternalId, context); var insertedRow = context.Match.AddMatchRow( match.StartTime, match.GameWeek, homeTeamRow, awayTeamRow, referee, assRef1, assRef2, match.Completed, match.ExternalId); insertedRow.AcceptChanges(); context.AcceptChanges(); foreach (var update in match.MatchUpdates) { AddMatchUpdate(update, insertedRow, context); } return(insertedRow.Id); } }
private static long AddMatchUpdate(MatchUpdate update, StffContext.MatchRow match, StffContext context) { var playerRow = context.Player.Where(p => p.ExternalId == update.Player.ExternalId).Single(); var insertedRow = context.MatchUpdate.AddMatchUpdateRow(update.Type.ToString(), update.Minute, playerRow, match, update.HomeTeam); insertedRow.AcceptChanges(); context.AcceptChanges(); return(insertedRow.Id); }
public static long AddPlayer(Player player, long teamId) { using (var context = new StffContext()) { var teamRow = context.Team.Where(t => t.Id == teamId).Single(); var insertedRow = context.Player.AddPlayerRow(teamRow, player.FirstName, player.LastName, player.ExternalId); insertedRow.AcceptChanges(); context.AcceptChanges(); return(insertedRow.Id); } }
public static long AddReferee(Referee referee) { using (var context = new StffContext()) { var insertedRow = context.Referee.AddRefereeRow(referee.FirstName, referee.LastName, referee.Location, referee.ExternalId); insertedRow.SetAdded(); insertedRow.AcceptChanges(); context.AcceptChanges(); return(insertedRow.Id); } }