public async Task <int?> CreateCustomer(CustomerRequest customer) { var customers = await _customerDataAgent.GetAllCustomers(); var customerObject = _customerMapper.MapToDomain(customer); if (_customerDomainService.CanCreateCustomer(customerObject, customers)) { var createdCustomerId = await _customerDataAgent.CreateCustomer(customerObject); _logger.Information($"Customer created. Id - {createdCustomerId}"); return(createdCustomerId); } return(null); }
public async Task <List <Customer> > GetAllCustomers() { var customers = await _customerRepository.GetAll(); return(customers.Select(x => _customerMapper.MapToDomain(x)).ToList()); }