Example #1
0
        public async Task <IActionResult> RollbackOrdersWithProductConfirmed(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var product = await _context.Products.Include(p => p.Orders).SingleOrDefaultAsync(p => p.Id == id);

            if (product == null)
            {
                return(NotFound());
            }

            _context.RemoveRange(product.Orders);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }