public async Task <IActionResult> Delete(int id) { var value = await repository.GetValue(id); if (value != null) { var questions = await repository.GetQuestionsFromValues(id); foreach (var question in questions) { repository.Delete(question); } var photos = value.Photos.ToList(); foreach (var photo in photos) { await DeletePhoto(photo); } repository.Delete(value); } await context.SaveChangesAsync(); return(Ok(value)); }