private async void GetOnePost(object sender, RoutedEventArgs e) { var addPost = new AddPost(); try { var response = await client.GetAsync("api/postapi/" + PostId.Text); var post = await response.Content.ReadAsAsync<Post>(); if (post != null) { addPost.TitleTextBox.Text = post.Title; addPost.DescriptionTextBox.Text = post.ShortDescription; addPost.TagsTextBox.Text = String.Empty; foreach (var tag in post.Tags) { addPost.TagsTextBox.Text += tag.Content + " "; } addPost.Chapter1TitleTextBox.Text = post.Chapters.ToList()[0].Title; addPost.Chapter1DescriptionTextBox.Text = post.Chapters.ToList()[0].Content; addPost.Chapter2TitleTextBox.Text = post.Chapters.ToList()[1].Title; addPost.Chapter2DescriptionTextBox.Text = post.Chapters.ToList()[1].Content; addPost.Id.Text = PostId.Text; addPost.SendButton.Content = "Update"; addPost.ShowDialog(); } else { MessageBox.Show("Error ID"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AddPost(object sender, RoutedEventArgs e) { var addPost = new AddPost(); addPost.ShowDialog(); }