private async Task DeleteRestOfEntities(Client client) { var objects = _context.Objects.Where(o => o.ClientId == client.Id); if (objects.Any()) { foreach (var obj in objects) { var problems = _context.Problems.Where(p => p.ObjectId == obj.Id); if (problems.Any()) { foreach (var problem in problems) { var tasks = _context.Tasks.Where(t => t.ProblemId == problem.Id); if (tasks.Any()) { foreach (var t in tasks) { await DeleteUtils.DeleteTask(t, _context); } } await DeleteUtils.DeleteProblem(problem, _context); } } await DeleteUtils.DeleteObject(obj, _context); } } }
private async Task DeleteRestOfEntities(WorkshopObject obj) { var problems = _context.Problems.Where(p => p.ObjectId == obj.Id); if (problems.Any()) { foreach (var problem in problems) { var tasks = _context.Tasks.Where(t => t.ProblemId == problem.Id); if (tasks.Any()) { foreach (var t in tasks) { await DeleteUtils.DeleteTask(t, _context); } } await DeleteUtils.DeleteProblem(problem, _context); } } }