public async Task <ActionResult <RecipeDTO> > DeleteRecipe(Guid id) { //1. Checks var recipes = await recipeRepo.GetByExpressionAsync(c => c.Id == id); if (recipes == null || recipes.Count() == 0) { return(NotFound(new { message = "Gerecht niet gevonden." })); } Recipe recipe = recipes.FirstOrDefault <Recipe>(); //2. try/catch op de actie try { await recipeRepo.Delete(recipe); } catch { return(RedirectToAction("HandleErrorCode", "Error", new { statusCode = 400, errorMessage = $"Het verwijderen van gerecht '{recipe.RecipeName}' is mislukt." })); } return(Ok(mapper.Map <RecipeDTO>(recipe))); }