public void DeleteRightPlayer(TeamsTournament player) { try { if (player == null) { return; } var result = MessageBox.Show( "Вы действительно хотите удалить \"" + player.TeamName + "\"", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } var playersTeamsToDelete = Context.PlayersTeams .Where(p => p.TeamsTournamentId == player.TeamsTournamentId) .ToList(); foreach (var playersTeam in playersTeamsToDelete) { Context.PlayersTeams.Local.Remove(playersTeam); } Context.TeamsTournaments.Local.Remove(player); Context.SaveChanges(); } catch { MessageBox.Show("Не удалось удалить запись", "Удаление", MessageBoxButton.OK, MessageBoxImage.Error); } }
public TeamsTournament TournamentTeamAdd(Event eEvent) { TeamsTournament teamsTournament = new TeamsTournament() { EventId = eEvent.EventId, SeedingNumber = 0 }; Context.TeamsTournaments.Local.Add(teamsTournament); return(teamsTournament); }