private void Publish_Click(object sender, RoutedEventArgs e) { if (Title.Text.Equals("") || Content.Text.Equals("")) { ErrorMessage.Visibility = Visibility.Visible; } else { Article article = new Article(); article.PostContent.ContentTitle = Title.Text; article.PostContent.Content = Content.Text; article.Author = MainWindow.doctor; article.Date = DateTime.Today; string relativePath = ""; string[] parts = imagePath.Split("\\"); for (int i = 0; i < parts.Length; i++) { if (parts[i].Equals("Resources")) { relativePath = "/" + parts[i] + "/" + parts[i + 1]; } } article.Image = relativePath; articleController.AddArticle(article); ClosePage(); } }