private async void OnContactTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                if (nameLabel.Text == null || nameLabel.Text == "")
                {
                    throw new Exception("Please, enter the thread name!");
                }
                if (e.Item != null)
                {
                    var contact = (Contacts)e.Item;

                    CMessageThread thread;
                    using (Context context = new Context(settings.Config))
                    {
                        thread = new CMessageThread(context, nameLabel.Text, false, contact.PublicId, settings.UserPublicId);
                        PushOperations.Insert(context, thread, contact.PublicId, settings.UserPublicId);
                    }
                    await Navigation.PopModalAsync();

                    await app.MainPage.Navigation.PushModalAsync(new NavigationPage(new MessageView(app, thread.PublicId)));
                }
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
Exemple #2
0
 static void PostThread(long userId, string name)
 {
     using (Context context = new Context(config))
     {
         CMessageThread thread = new CMessageThread(context, name, false, userId, settings.UserPublicId);
         PushOperations.Insert(context, thread, userId, settings.UserPublicId);
         context.SaveChanges();
     }
 }