예제 #1
0
        private async void SendMessageToSingleButtonClick(object sender, RoutedEventArgs e)
        {
            if (ApiList.Count == 0)
            {
                MessageBox.Show($"At least one username MUST be login first"
                                , "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                var currentUsername = SessionsCombo.SelectedItem.ToString();
                var firstApi        = ApiList.FirstOrDefault(api => api.GetLoggedUser().LoggedInUser.UserName.ToLower() == currentUsername);
                var userToText      = await firstApi.UserProcessor.GetUserAsync("ministaapp");

                var textToSend = MessageText.Text;
                if (string.IsNullOrEmpty(textToSend))
                {
                    textToSend = "This is a test message";
                }
                if (userToText.Succeeded)
                {
                    var directText = await firstApi.MessagingProcessor.SendDirectTextAsync(userToText.Value.Pk.ToString(), null, textToSend);

                    if (directText.Succeeded)
                    {
                        // your message sent successfully
                    }
                    else
                    {
                        // an error occured
                    }
                }
            }
        }
        public static void SetAttribute <T>(this ApiList <IExtendedAttribute> attributes, string name, T value)
        {
            IExtendedAttribute attribute = attributes.FirstOrDefault(f => f.Key == name);

            if (attribute == null)
            {
                attribute = new ExtendedAttribute()
                {
                    Key = name
                };
                attributes.Add(attribute);
            }

            attribute.Value = Convert.ToString(value);
        }