Example #1
0
        public async Task <int> DeleteAsync(int id)
        {
            try
            {
                Customer customer = await GetCustomerByIdAsync(id);

                if (customer == null)
                {
                    throw new EntityNotFoundException($"There is no Customer with Id {id}");
                }

                _dbContext.Remove(customer);
                return(await _dbContext.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error occurred");
                throw;
            }
        }
Example #2
0
 public async Task DeleteAsync(Customer customer)
 {
     _context.Remove(customer);
     await _context.SaveChangesAsync();
 }