public BaseViewModel() { var luisService = new LuisService(); DoTask = new Command(async() => { var intent = await luisService.GetRecognizedIntent(); switch (intent.TopScoringIntent.Intent) { case "Note.Create": switch (intent.Entities.Count) { case 1 when intent.Entities.First().Type == "Note.Title": await Application.Current.MainPage.Navigation.PushAsync(new AddNotePage(intent.Entities.First().Value)); break; case 2 when intent.Entities.Any(x => x.Type == "Note.Title") && intent.Entities.Any(x => x.Type == "Note.Text"): await Application.Current.MainPage.Navigation.PushAsync( new AddNotePage(intent.Entities.First(x => x.Type == "Note.Title").Value, intent.Entities.First(a => a.Type == "Note.Text").Value)); break; default: await Application.Current.MainPage.Navigation.PushAsync(new AddNotePage()); break; } break; case "Note.Open": if (intent.Entities.Count == 1 && intent.Entities.First().Type == "Note.Title") { var noteService = new NoteService(((User)Application.Current.Properties["user"]).JwtToken); var notes = JsonConvert.DeserializeObject <List <Note> >(await noteService.GetAll(((User)Application.Current.Properties["user"]).Id)); var foundNote = notes.SingleOrDefault(x => x.Title == intent.Entities.First().Value); if (foundNote == default) { await TextToSpeech.SpeakAsync("The note was not in the database."); } else { await Application.Current.MainPage.Navigation.PushAsync( new NoteEntryPage(foundNote.Id)); } } break; // Update // Delete case "None": return; default: return; } }); }