public async Task <IActionResult> Delete(int?id) { if (id != null) { ForumCategoryModel model = await _db.ForumCategories .Include(t => (t.Topics as TopicModel).Replies) .ThenInclude(t => t.Pictures) .Include(t => (t.Topics as TopicModel).Pictures) .Include(t => t.Topics) .FirstOrDefaultAsync(p => p.Id == id); if (model != null) { _db.DeleteForumCategory(model); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } } return(NotFound()); }