private async void ReplayCommandExecute() { MessageReplayViewModel replayViewModel = new MessageReplayViewModel(); replayViewModel.ScreenTitle = Constants.MessageScreenTitle; await App.Current.MainPage.Navigation.PushAsync(new MessageReplyPage(), false); }
private async Task SendMessage() { try { if (TypedMessage == null || TypedMessage == "" || string.IsNullOrWhiteSpace(TypedMessage)) { return; } else { var message = !string.IsNullOrEmpty(TypedMessage.Trim()) ? TypedMessage.Trim() : string.Empty; var values = new Dictionary <object, object> { { "author", userId }, { "threadId", threadId }, { "plainContent", message }, { "createdDate", DateTime.Now.ToUniversalTime() }, { "memoToFile", null }, { "sendToOfficer", false }, }; httpClient = new HttpClient(); var content = new StringContent(JsonConvert.SerializeObject(values), Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(Config.SAVE_MESSAGE_API, content); if (response.StatusCode != System.Net.HttpStatusCode.OK || response.Content == null) { await ClosePopup(); Device.BeginInvokeOnMainThread(async() => { await ShowAlert("Data Not Sent!!", string.Format("Response contained status code: {0}", response.StatusCode)); }); } else { await ClosePopup(); var content1 = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content1); TypedMessage = null; Settings.TypedMessage = TypedMessage; MessageReplayViewModel thisVm = new MessageReplayViewModel(); await FetchThreadUserData(); //await SendThreadUsersAsync(); //await ShowAlertWithAction("Success", content1, "Ok", "Cancel"); //var yesSelected = await DisplayAlert("Simon", content, "Ok", "Cancel"); // the call is awaited //if (yesSelected) // No compile error, as the result will be bool, since we awaited the Task<bool> //{ // await Navigation.PopToRootAsync(); //} //else { return; } } } } catch (Exception ex) { await ClosePopup(); ShowExceptionAlert(ex); } finally { await ClosePopup(); } }