AspNetCorePostgreSQLDockerApp.Repository.CustomersRepository.DeleteCustomerAsync C# (CSharp) Method

DeleteCustomerAsync() public method

public DeleteCustomerAsync ( int id ) : Task
id int
return Task
        public async Task<bool> DeleteCustomerAsync(int id)
        {
            //Extra hop to the database but keeps it nice and simple for this demo
            var customer = await _context.Customers.SingleOrDefaultAsync(c => c.Id == id);
            _context.Remove(customer);
            try
            {
              return (await _context.SaveChangesAsync() > 0 ? true : false);
            }
            catch (System.Exception exp)
            {
               _logger.LogError($"Error in {nameof(DeleteCustomerAsync)}: " + exp.Message);
            }
            return false;
        }