private void btn_postComment_Click(object sender, RoutedEventArgs e) { DataFlow dataFlow = new DataFlow(); if (!dataFlow.SetConnectionStatus()) { MessageService.ShowMessage("Error", "In order to comment you need an internet connection"); return; } if (ShowCountry.Count == 0) { return; } var country = ShowCountry.FirstOrDefault(); if (!string.IsNullOrWhiteSpace(tb_post.Text) && country != null) { var date = DateTime.Now; Comment comment = new Comment { Alphacode = country.Alpha2Code, Comments = tb_post.Text, Date = date }; MessageBoxResult result = MessageBox.Show("Your Post was successfully completed", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { Task.Run(() => dataFlow.PostCommentsData(country, comment)); gb_Comments.Visibility = Visibility.Collapsed; gb_Comments.Visibility = Visibility.Visible; CommentsCountry.Add(comment); } else { tb_post.Text = string.Empty; return; } } else { MessageService.ShowMessage("", "Please write a comment"); } ShowComment(); }