public IActionResult DeleteConfirmed(int id) { ViewBag.thisStep = stepRepo.Steps .Include(p => p.Project) .ThenInclude(m => m.Module) .ThenInclude(q => q.QUESTOR) .FirstOrDefault(x => x.StepId == id); var step = stepRepo.Steps.FirstOrDefault(x => x.StepId == id); Step thisStep = stepRepo.Steps.FirstOrDefault(x => x.StepId == id); stepRepo.Remove(thisStep); return(RedirectToAction("Edit", "QUESTORs", new { id = ViewBag.thisStep.Project.Module.QUESTORId })); }