コード例 #1
0
        public bool SaveTeam(Team team)
        {
            try
            {
                if (!Teams.Contains(team))
                {
                    Teams.Add(team);
                }

                Task.Run(() =>
                {
                    SaveItem(team);
                });

                return true;
            }
            catch (Exception e)
            {
                Task ExceptionTask = Task.Run(() => ExceptionHandler.instance.PostException(new AppException(e, (int)BaseLogic.ClientIDHandler.ClientIDHandler.AppName._30Seconds)));
                return false;
            }
        }
コード例 #2
0
 public async void EditTeamButton(Team team)
 {
     PlayersPageViewModel.instance.CurrentTeam = team;
     await Navigate(typeof(PlayersPage));
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public void AddNewTeamToGameButton()
        {
            int TeamCount = TeamHandler.instance.GetTeamsFromDatabase().Count > 0 ? (TeamHandler.instance.GetTeamsFromDatabase().Max(t => t.InternalID) + 1) : 1;

            Team NewTeam = new Team()
            {
                GameID = CurrentGame.InternalID,
                Players = new ObservableCollection<Player>(),
                Points = 0,
                Name = "Team" + TeamCount
            };

            CurrentGame.Teams.Add(NewTeam);
            TeamHandler.instance.SaveTeam(NewTeam);
        }
コード例 #5
0
        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);
            });
        }
コード例 #6
0
 public void DeleteTeam(Team team)
 {
     DeleteItem(team);
     Teams.Remove(team);
 }
コード例 #7
0
 public List<Player> GetPlayersByTeam(Team Team)
 {
     return Players.Where(p => p.TeamID == Team.InternalID).ToList();
 }