Beispiel #1
0
        public async Task DeleteAsync(int id)
        {
            var client = await context.Client.FindAsync(id);

            context.Remove(client);
            await context.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task DeleteAsync(int id)
        {
            try
            {
                var product = await context.Product.FindAsync(id);

                context.Remove(product);
                await context.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                throw new IntegrityException("Can't delete product because it has sales associated.");
            }
        }