Пример #1
0
        private async void DeletePLayer()
        {
            // get player selected

            var player_d = (GameItemsViewModel)this.IsSelectD;

            if (player_d == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Jugador no seleccionado",
                    "No se selecciono ningún jugador para eliminar",
                    "Aceptar");

                return;
            }

            var action = await Application.Current.MainPage.DisplayAlert(
                "Eliminar jugador",
                "Desea eliminar el jugador " + player_d.Namep + " Seleccionado",
                "Si",
                "Cancelar");

            if (!action)
            {
                return;
            }

            // Delete player in BD
            var mainViewModel = MainViewModel.GetInstance();
            var sqlcon        = mainViewModel.Games.sqlcon;

            var player_delete = new Players
            {
                IdGame   = player_d.IdGame,
                IdPLayer = player_d.IdPLayer
            };

            var response = await sqlCon.DeleteReg(player_delete);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    response.Message,
                    "Aceptar");
            }
            else
            {
                mainViewModel.PlayerList.Remove(player_delete);
                mainViewModel.Game.Players.Remove(player_d);
            }
        }