public IActionResult Delete(SocketDeleteViewModel model) { List <TimeTask> timeTasks = _timeTaskRepository.TimeTasks .Include(tt => tt.Socket) .Where(tt => tt.Socket.SocketId == model.SocketId) .ToList(); foreach (TimeTask timeTask in timeTasks) { BackgroundJob.Delete(timeTask.BackgroundJobId); } _socketRepository.DeleteSocket(model.SocketId); _socketRepository.Savechanges(); return(RedirectToAction("Index", "Socket")); }