public void DeleteTest() { List <Answer> answers = AnswerManager.Load(); Answer answer = answers.FirstOrDefault(a => a.Text == "Waffles"); int results = AnswerManager.Delete(answer.Id, true); Assert.IsTrue(results > 0); }
public IActionResult Delete(int id) { try { if (answerManager.Get(id) == null) { return(NotFound(id)); } answerManager.Delete(id); } catch (Exception ex) { logger.LogError($"Failed to delete answer {id}: {ex}"); return(BadRequest(config["Error:Default"])); } return(NoContent()); }
private void Button_Click(object sender, RoutedEventArgs e) { try { switch (mode) { case Mode.Answer: AnswerManager.Delete(answers[cboAttribute.SelectedIndex].Id); break; case Mode.Question: QuestionManager.Delete(questions[cboAttribute.SelectedIndex].Id); break; } Reload(); } catch (Exception) { MessageBox.Show("This is required for an existing question. Unpair to delete"); } }