public async Task <IActionResult> Delete(int id) { Order order = await _context.Orders.FirstOrDefaultAsync(o => o.Id == id); if (order != null) { var item = _context.OrderItems.Include("Car").Where(o => o.OrderId == order.Id); foreach (var oitem in item) { oitem.Car.Status = true; } _context.RemoveRange(item); _context.Orders.Remove(order); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } return(NotFound()); }