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