public IActionResult Delete([FromBody] IDRequest request) { if (!ModelState.IsValid) { return(Ok(ModelState)); } var response = new BaseResponse <bool>(); var item = recipeRepo.GetById(request.Id); if (item == null) { return(NotFound()); } var ingredients = ingredientRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (ingredients.Any()) { ingredientRepo.DeleteRange(ingredients); } var steps = stepRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (steps.Any()) { stepRepo.DeleteRange(steps); } var images = imageRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (images.Any()) { imageRepo.DeleteRange(images); } var recipeCategory = categoryRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (recipeCategory.Any()) { categoryRepo.DeleteRange(recipeCategory); } var rates = rateRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (rates.Any()) { rateRepo.DeleteRange(rates); } var bookmarks = bookMarkRepo.GetBy(x => x.RecipeID == item.Id).ToList(); if (bookmarks.Any()) { bookMarkRepo.DeleteRange(bookmarks); } recipeRepo.Delete(item); response.Message = "Yemek tarifi başarıyla silinmiştir."; return(Ok(response)); }