public async Task LoadData()
        {
            IsLoading = true;

            CurrentGame = GameHandler.instance.GetCurrentGame();
            CurrentTeam = TeamHandler.instance.GetTeamByID(CurrentGame.CurrentTeamID.Value);
            CurrentPlayer = PlayerHandler.instance.GetPlayerByID(CurrentTeam.CurrentPlayerID.Value);
            NotifyPropertyChanged("CurrentPlayer");
            NotifyPropertyChanged("CurrentTeam");

            NavigatedTo();

            IsLoading = false;

        }
Ejemplo n.º 2
0
        public bool SavePlayer(Player player)
        {
            try
            {
                if (!this.Players.Contains(player))
                {
                    this.Players.Add(player);
                }

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

                return true;
            }
            catch (Exception e)
            {
                Task ExceptionTask = Task.Run(() => ExceptionHandler.instance.PostException(new AppException(e, (int)BaseLogic.ClientIDHandler.ClientIDHandler.AppName._30Seconds)));
                return false;
            }
        }
Ejemplo n.º 3
0
        public bool SavePlayers(Player[] Players)
        {
            try
            {
                bool Result = true;

                foreach (Player p in Players)
                {
                    bool SaveResult = SavePlayer(p);

                    if (!SaveResult)
                    {
                        Result = !Result ? SaveResult : false;
                    }
                }

                return Result;
            }
            catch (Exception e)
            {
                Task ExceptionTask = Task.Run(() => ExceptionHandler.instance.PostException(new AppException(e, (int)BaseLogic.ClientIDHandler.ClientIDHandler.AppName._30Seconds)));
                return false;
            }
        }
        public void AddNewPlayerButton()
        {
            List<Player> Players = PlayerHandler.instance.GetPlayersFromDatabase();

            Player NewPlayer = new Player()
            {
                Name = "Player" + (Players.Count > 0 ? Players.Max(p => p.InternalID) + 1 : 1),
                GameID = GameHandler.instance.GetCurrentGame().InternalID,
                TeamID = CurrentTeam.InternalID,
                GamesPlayed = 0,
            };

            PlayerHandler.instance.SavePlayer(NewPlayer);

            CurrentTeam.Players.Add(NewPlayer);
        }
        public async Task DeletePlayerButton(Player PlayerToDelete)
        {
            if (PlayerToDelete.GameID != CurrentTeam.GameID)
            {
                ////Create warning dialog:
                var messageDialog = new MessageDialog(string.Format(Utils.ResourceLoader.GetString("text_DeletePlayerQuestion_Body"), PlayerToDelete.Name), Utils.ResourceLoader.GetString("text_DeletePlayerQuestion_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)
                {
                    PlayerHandler.instance.DeletePlayer(PlayerToDelete);
                    ExistingPlayers.Remove(PlayerToDelete);
                }
            }
            else
            {
                CurrentTeam.Players.Remove(PlayerToDelete);
                ExistingPlayers.Add(PlayerToDelete);

                PlayerToDelete.GameID = 0;
                PlayerToDelete.TeamID = 0;
                PlayerHandler.instance.SavePlayer(PlayerToDelete);
            }
        }
        public void AddExistingPlayerButton(Player ExistingPlayer)
        {
            CurrentTeam.Players.Add(ExistingPlayer);
            ExistingPlayers.Remove(ExistingPlayer);

            ExistingPlayer.TeamID = CurrentTeam.InternalID;
            ExistingPlayer.GameID = GameHandler.instance.GetCurrentGame().InternalID;
            Task.Run(() =>
                {
                    PlayerHandler.instance.SavePlayer(ExistingPlayer);
                });
        }
 public async void EditPlayerButton(Player player)
 {
     PlayerPageViewModel.instance.CurrentPlayer = player;
     await Navigate(typeof(PlayerPage));
 }
Ejemplo n.º 8
0
 public void DeletePlayer(Player player)
 {
     DeleteItem(player);
     Players.Remove(player);
 }