Ejemplo n.º 1
0
 private async void UpdateCheckedTodoItem(Message item)
 {
     // This code takes a freshly completed Message and updates the database. When the MobileService 
     // responds, the item is removed from the list 
     //await todoTable.UpdateAsync(item);
     //items.Remove(item);
 }
Ejemplo n.º 2
0
 private async void InsertTodoItem(Message message)
 {
     try
     {
         // This code inserts a new Message into the database. When the operation completes
         // and Mobile Services has assigned an Id, the item is added to the CollectionView
         //await todoTable.InsertAsync(message);
         //items.Add(message);
     }
     catch (Exception ex)
     {
         ex.ToString();
     }
 }
Ejemplo n.º 3
0
        private async void ExecuteSendChatMessageCommand()
        {
            string content = CurrentMessage;
            if (String.IsNullOrWhiteSpace(content) == false)
            {
                try
                {
                    ObservableCollection<MessageForUI> messages = _chatConversations[_selectedFriend.Id];
                    if (messages == null)
                    {
                        throw new Exception("null");
                    }

                    messages.Add(new MessageForUI
                    {
                        ChatBubbleDirection = ChatBubbleDirection.LowerRight,
                        Alignment = Windows.UI.Xaml.HorizontalAlignment.Right,
                        FromId = App.CurrentUser.ProviderIdLong,
                        Content = content
                    });

                    if (App.ChatPageReference != null)
                    {
                        App.ChatPageReference.ScrollToLastElement();
                    }

                    MessagesViewModel = messages;

                    var message = new Message
                    {
                        Id = Guid.NewGuid().ToString(),
                        Content = content,
                        DeviceType = Enums.DeviceType.Windows8,
                        FromId = App.CurrentUser.ProviderIdLong,
                        FromName = App.CurrentUser.Name,
                        FromPicture = App.CurrentUser.Picture,
                        ToId = _selectedFriend.Id
                    };

                    CurrentMessage = String.Empty;
                    RaisePropertyChanged("CurrentMessage");

                    try
                    {
                        await App.MessagesTable.InsertAsync(message);
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
        }
Ejemplo n.º 4
0
 private void ButtonSave_Click(object sender, RoutedEventArgs e)
 {
     var todoItem = new Message { Content = TodoInput.Text };
     InsertTodoItem(todoItem);
 }