/// <summary> /// Save button functionality. /// Calls methods ValidatePost() and BuildData() /// Asks user confirmation to validate saving or chance to back out. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SaveNewPost(object sender, RoutedEventArgs e) { if (this.ValidatePost()) { MessageBoxResult wannaInsert = MessageBox.Show("Are you sure you want to add post?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (wannaInsert == MessageBoxResult.Yes) { CollectionHandler collectionHandler = new CollectionHandler(); FirebaseHandler firebaseHandler = new FirebaseHandler(); string[] response = await firebaseHandler.SaveToDb(this.BuildData(), collectionHandler.GetBlogCollection(localesDrobdown.Text)); if (response[0].Equals("200")) { _ = MessageBox.Show("Blog post added", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } else { _ = MessageBox.Show(response[1], "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { _ = MessageBox.Show("Inserting cancelled!", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } } else { _ = MessageBox.Show("Some fields are empty", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } }