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====================="); } }); }
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); }