Beispiel #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string     login_requested = login_input.Text;
            AccountDTO account2sent    = await authcore.GetAccountByLoginAsync(login_requested);

            if (account2sent != null)
            {
                MessageDTO message2sent = new MessageDTO();
                message2sent.Content    = msgBox.Text;
                message2sent.SenderId   = UserCredentials.Account.AccountId;
                message2sent.ReceiverId = account2sent.AccountId;
                message2sent.Date       = DateTime.Now;
                bool respond = await msgcore.AddMessageAsync(message2sent);

                if (respond)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The login is correct but there was a server error while sending message. Please try again");
                }
            }
            else
            {
                MessageBox.Show("The login is incorrect");
            }
        }
Beispiel #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            int        targetReceiver = getSelectedContactId();
            MessageDTO msg_to_be_sent = new MessageDTO();

            msg_to_be_sent.Content    = userinputmessageBox.Text.Trim();
            msg_to_be_sent.SenderId   = UserCredentials.Account.AccountId;
            msg_to_be_sent.ReceiverId = targetReceiver;
            msg_to_be_sent.Date       = DateTime.Now;

            bool response = await core.AddMessageAsync(msg_to_be_sent);

            if (response)
            {
                userinputmessageBox.Text = "success";
                LoadRecentMessagesImmediately();
                var targetedConversation = await core.GetMessagesByTargetIdAsync(CurrentUserAccountID, targetReceiver);

                DisplayMessages(targetedConversation, targetReceiver, true);
            }
            else
            {
                MessageBox.Show("Could not send the message");
            }
        }