Inheritance: Observable
        public int SaveDialog(DialogTable item, bool isNotify = false)
        {
            int retVal = 0;

            lock (locker)
            {
                var checkIfPresence = this.database.Table <DialogTable>().FirstOrDefault(x => x.DialogId == item.DialogId);
                if (checkIfPresence != null)
                {
                    retVal = item.ID = checkIfPresence.ID;
                    this.database.Update(item);
                }
                else
                {
                    this.database.Insert(item);
                    retVal = item.ID;
                }
            }

            if (isNotify)
            {
                dialogObserver.Invoke();
            }
            return(retVal);
        }
        public async Task<DialogTable> UpdateInDialogMessage(string chatDialogId, Message message)
        {
            var dialog = Database.Instance().GetDialog(chatDialogId);
            if (dialog == null)
            {
                var dialogInfo = await App.QbProvider.GetDialogAsync(chatDialogId);
                if (dialogInfo == null)
                {
                    return null;
                }
                dialog = new DialogTable(dialogInfo);
            }
            if (dialog != null)
            {
                dialog.LastMessage = System.Net.WebUtility.UrlDecode(message.MessageText);
                dialog.LastMessageSent = DateTime.UtcNow;
                if (dialog.UnreadMessageCount != null)
                {
                    dialog.UnreadMessageCount++;
                }
                else {
                    dialog.UnreadMessageCount = 1;
                }
                Database.Instance().SaveDialog(dialog);
            }

            return dialog;
        }
		private void SaveDialogToDb(Dialog dialog)
		{
			if (dialog != null)
			{
				var dialogTable = new DialogTable(dialog);
				dialogTable.LastMessageSent = DateTime.UtcNow;
				Database.Instance().SaveDialog(dialogTable);
			}
		}
 public void AddDialogToList(DialogTable dialogTable)
 {
     lock (dialogAddLock)
     {
         var dialog = Dialogs.FirstOrDefault((d => d.DialogId == dialogTable.DialogId));
         if (dialog == null)
         {
             Dialogs.Insert(0, dialogTable);
         }
         else
         {
             if (Dialogs.IndexOf(dialog) == 0)
             {
                 dialog.LastMessage = dialogTable.LastMessage;
                 dialog.LastMessageSent = dialogTable.LastMessageSent;
             }
             else
             {
                 Dialogs.Remove(dialog);
                 Dialogs.Insert(0, dialogTable);
             }
         }
     }
 }
        private void OnSystemMessageReceived(object sender, SystemMessageEventArgs messageEventArgs)
        {
            var groupMessage = messageEventArgs.Message as GroupInfoMessage;
            if (groupMessage != null)
            {
                var dialog = new DialogTable
                {
                    DialogId = groupMessage.DialogId,
                    DialogType = groupMessage.DialogType,
                    LastMessage = "Notification message",
                    LastMessageSent = groupMessage.DateSent,
                    Name = groupMessage.RoomName,
                    Photo = groupMessage.RoomPhoto,
                    OccupantIds = string.Join(",", groupMessage.CurrentOccupantsIds),
                    XmppRoomJid = String.Format("{0}_{1}@{2}", ApplicationKeys.ApplicationId, groupMessage.DialogId, ApplicationKeys.ChatMucEndpoint)
                };

                App.QbProvider.GetXmppClient().JoinToGroup(dialog.XmppRoomJid, App.QbProvider.UserId.ToString());
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
               () =>
               {
                   AddDialogToList(dialog);
               });
                Database.Instance().SaveDialog(dialog);
            }
        }
 private void TappedCommandExecute(DialogTable dialogItem)
 {
     if (dialogItem.DialogType == Quickblox.Sdk.Modules.ChatModule.Models.DialogType.Private)
         App.NavigationFrame.Navigate(typeof(PrivateChatPage), dialogItem.DialogId);
     else
         App.NavigationFrame.Navigate(typeof(GroupChatPage), dialogItem.DialogId);
 }
 public void AddDialogToList(DialogTable dialogTable)
 {
     lock (dialogAddLock)
     {
         var dialog = Dialogs.FirstOrDefault((d => d.DialogId == dialogTable.DialogId));
         if (dialog == null)
         {
             Dialogs.Insert(0, dialogTable);
         }
         else
         {
             Dialogs.Remove(dialog);
             Dialogs.Insert(0, dialogTable);
         }
     }
 }
 private void TappedCommandExecute(DialogTable dialogItem)
 {
     if (dialogItem.DialogType == Quickblox.Sdk.Modules.ChatModule.Models.DialogType.Private)
         App.Navigation.PushAsync(new PrivateChatPage(dialogItem.DialogId));
     else
         App.Navigation.PushAsync(new GroupChatPage(dialogItem.DialogId));
 }
		public int SaveDialog(DialogTable item, bool isNotify = false)
        {
            int retVal = 0;
            lock (locker)
            {
                var checkIfPresence = this.database.Table<DialogTable>().FirstOrDefault(x => x.DialogId == item.DialogId);
                if (checkIfPresence != null)
                {
                    retVal = item.ID = checkIfPresence.ID;
                    this.database.Update(item);
                }
                else
                {
                    this.database.Insert(item);
                    retVal = item.ID;
                }
            }

			if (isNotify)
				dialogObserver.Invoke ();
            return retVal;
        }