Example #1
0
        public async Task <ActionResult <Customer> > DeleteCustomer(int id)
        {
            var customer = await _context.Customers.FindAsync(id);

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

            _context.RemoveRange(_context.Rentals.Where(r => r.CustomerId == id).ToList());
            _context.Customers.Remove(customer);
            await _context.SaveChangesAsync();

            return(customer);
        }