public CustomerDTO AddNewCustomer(CustomerDTO customerDTO) { //check preconditions if (customerDTO == null || customerDTO.CountryId == Guid.Empty) throw new ArgumentException(Messages.warning_CannotAddCustomerWithEmptyInformation); var country = _countryRepository.Get(customerDTO.CountryId); if (country != null) { //Create the entity and the required associated data var address = new Address(customerDTO.AddressCity, customerDTO.AddressZipCode, customerDTO.AddressAddressLine1, customerDTO.AddressAddressLine2); //TODO: usar factory var customer = Customer.CreateCustomer(customerDTO.FirstName, customerDTO.LastName, customerDTO.Telephone, customerDTO.Company, country, address); //save entity SaveCustomer(customer); //return the data with id and assigned default values //return customer.ProjectedAs<CustomerDTO>(); // TODO: fazer codigo de mapeamento ou usar mapper return customerDTO; } else return null; }
public void UpdateCustomer(CustomerDTO customerDTO) { throw new NotImplementedException(); }