Beispiel #1
0
 public CreatePlayerPageViewModel()
 {
     CreatePlayer = new Command(async() =>
     {
         await CreatePlayerInfo();
         Debug.WriteLine("===================Player Created=====================");
     });
     LoadPlayer = new Command(async() =>
     {
         foreach (var item in await App.Database.GetAllPlayer())
         {
             PlayerListView.Add(new CreatePlayerPageViewCellViewModel(item));
             Debug.WriteLine("===================Player Loaded=====================");
         }
     });
 }
Beispiel #2
0
        public async Task CreatePlayerInfo()
        {
            if (string.IsNullOrEmpty(FirstName) || string.IsNullOrEmpty(LastName))
            {
                await App._Navigation.DisplayAlert("Alert", "You have been alerted", "OK");

                return;
            }
            var NewPlayer = new Player()
            {
                FirstName = FirstName, LastName = LastName, DateOfBirth = DateOfBirth, Country = Country, Gender = Gender
            };

            Debug.WriteLine("--------------- CreatePlayer ----------- " + NewPlayer.FirstName + " " + NewPlayer.LastName + " " + NewPlayer.Gender + " " + NewPlayer.Country + " " + NewPlayer.DateOfBirth.ToString());

            PlayerListView.Add(new CreatePlayerPageViewCellViewModel((Player)NewPlayer));

            await App.Database.SavePlayer(NewPlayer);
        }