public async Task <ActionResult> Delete(Guid id, IFormCollection collection) { try { if (id == null) { throw new Exception("Bad Delete Request."); } IEnumerable <Questions> list = await questionsRepo.GetQuestionsByQuiz(id); foreach (Questions question in list) { await questionsRepo.Delete(question.QuestionID); } await quizrepo.Delete(id); return(RedirectToAction(nameof(Index))); } catch (Exception) { Debug.WriteLine($"Delete error. "); ModelState.AddModelError(String.Empty, "Delete failed."); return(View()); } }
public async Task <IActionResult> DeletQuiz(Guid?id) { if (id == null) { return(BadRequest("This enpoind requires a valid QuizId")); } await quizRepo.Delete(id ?? Guid.Empty); return(new StatusCodeResult(200)); }
public async Task <ActionResult> DeleteQuiz(Guid?id, IFormCollection collection) { try { if (id == null) { return(Redirect("/Error/400")); } await quizRepo.Delete(id ?? Guid.Empty); return(RedirectToAction(nameof(Index))); } catch (Exception exc) { ModelState.AddModelError("", "Delete failed " + exc); return(View()); } }
public async Task <ActionResult> Delete(Guid?id, IFormCollection collection) { try { if (ModelState.IsValid) { if (id == null) { throw new Exception("Bad Delete Request"); } var quiz = await quizRepo.GetAsync(id); quizRepo.Delete(quiz); await quizRepo.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View()); } }
public async Task <IActionResult> Delete(Guid id) { try { var quiz = await quizRepo.GetAsync(id); if (quiz == null) { return(NotFound()); } quizRepo.Delete(quiz); await quizRepo.SaveChangesAsync(); return(NoContent()); } catch (Exception ex) { logger.LogError(ex.Message); return(BadRequest("Verwijderen mislukt")); } }
public async Task <IActionResult> Delete(int id) { try { var foundQuiz = await _quizrepo.GetAsync(id); if (foundQuiz == null) { return(NotFound()); } _quizrepo.Delete(foundQuiz); await _quizrepo.SaveAsync(); return(NoContent()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest()); } }
public Task <int> Delete(int id) { return(_quizRepo.Delete(id)); }
public async Task <IActionResult> DeleteAsync(Guid id) { await quizRepo.Delete(id); return(Ok("DELETE was succesfull")); }