public void AddTeamToGameButton(Team team) { CurrentGame.Teams.Add(team); ExistingTeams.Remove(team); team.GameID = CurrentGame.InternalID; foreach (Player p in team.Players) { p.GameID = CurrentGame.InternalID; } Task.Run(() => { PlayerHandler.instance.SavePlayers(team.Players.ToArray()); TeamHandler.instance.SaveTeam(team); }); }
public async Task DeleteTeamButton(Team TeamToDelete) { if (TeamToDelete.GameID != CurrentGame.InternalID) { ////Create warning dialog: var messageDialog = new MessageDialog(string.Format(Utils.ResourceLoader.GetString("text_DeleteTeamQuestion_Body"), TeamToDelete.Name), Utils.ResourceLoader.GetString("text_DeleteTeamQuestion_Title")); messageDialog.Commands.Add( new UICommand( Utils.ResourceLoader.GetString("text_Delete"), null, 0)); messageDialog.Commands.Add( new UICommand( Utils.ResourceLoader.GetString("text_Cancel"), null, 1)); // Set the command that will be invoked by default messageDialog.DefaultCommandIndex = 0; // Set the command to be invoked when escape is pressed messageDialog.CancelCommandIndex = 1; IUICommand Command = await messageDialog.ShowAsync(); if ((int)Command.Id == 0) { TeamHandler.instance.DeleteTeam(TeamToDelete); ExistingTeams.Remove(TeamToDelete); } } else { CurrentGame.Teams.Remove(TeamToDelete); ExistingTeams.Add(TeamToDelete); TeamToDelete.GameID = 0; TeamHandler.instance.SaveTeam(TeamToDelete); } }