private void SendMessageCommandExecute(object obj) { var message = this.MessageText != null?this.MessageText.Trim() : string.Empty; if (!string.IsNullOrEmpty(message)) { try { var encodedMessage = System.Net.WebUtility.UrlEncode(message); groupChatManager.SendMessage(encodedMessage); } catch (Exception ex) { App.Current.MainPage.DisplayAlert("Internet connection", "Internet connection is lost. Please check it and restart the Application", "Ok"); } finally { this.MessageText = ""; } } }
private void SendMessageCommandExecute() { var message = this.MessageText != null?this.MessageText.Trim() : string.Empty; if (!string.IsNullOrEmpty(message)) { var m = new MessageTable(); m.SenderId = (int)App.QbProvider.UserId; m.Text = message; m.DialogId = dialogId; m.RecepientFullName = "Me"; long unixTimestamp = DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks; unixTimestamp /= TimeSpan.TicksPerSecond; m.DateSent = unixTimestamp; m.ID = Database.Instance().SaveMessage(m); var dialog = Database.Instance().GetDialog(this.dialogId); dialog.LastMessage = m.Text; dialog.LastMessageSent = DateTime.UtcNow; Database.Instance().SaveDialog(dialog); try { var encodedMessage = System.Net.WebUtility.UrlEncode(message); groupChatManager.SendMessage(encodedMessage); } catch (Exception ex) { new MessageDialog("Internet connection is lost. Please check it and restart the Application", "Error").ShowAsync(); } finally { MessageText = ""; } } }