private async Task ExecuteCreateGameCommand() { string gameName = GameNameEntryText.Trim(); string gamePin = GamePinEntryText.Trim(); bool result = await PlayersHub.Connection.InvokeAsync <bool>("GameNameExistsInPool", gameName); if (!result) { bool answer = await App.Current.MainPage.DisplayAlert("New Game", $"{MinimumCount} minimum players. Sure?", "Yes", "No"); if (answer) { Guid newGameGuid = await PlayersHub.Connection.InvokeAsync <Guid>("CreateGame", gameName, gamePin, MinimumCount); DependencyService.Get <IMessage>().ShortAlert($"Game {gameName} have been created"); GameNameEntryText = ""; await JoinGame(newGameGuid, gamePin); } } else { DependencyService.Get <IMessage>().ShortAlert($"Game {gameName} existing on server"); } }
public CreateVM() { CreateCommand = new Command( execute: async(o) => { await ExecuteCreateGameCommand(); }, canExecute: (o) => { string gameName = GameNameEntryText.Trim(); string gamePin = GamePinEntryText.Trim(); if (!String.IsNullOrEmpty(gameName) && !String.IsNullOrEmpty(gamePin)) { return(true); } else { return(false); } }); }