public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); _customerRepository.Save(customer); _customerRepository.FetchAll(); }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); customer.Address = _customerAddressFormatter.For(customerToCreate); _customerRepository.Save(customer); }
public void Create(CustomerToCreateDto customerToCreateDto) { var fullName = _customerFullName.From( customerToCreateDto.FirstName, customerToCreateDto.LastName); var customer = new Customer(fullName); _customerRepository.Save(customer); }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); var addressFormatter = _addressFormatterFactory.From( customerToCreate.Country); customer.Address = addressFormatter.From(customerToCreate); _customerRepository.Save(customer); }
public void Create(CustomerToCreateDto customerToCreate) { try { var customer = new Customer(customerToCreate.Name); customer.Address = _customerAddressFactory.From(customerToCreate); _customerRepository.Save(customer); } catch (InvalidCustomerAddressException e) { throw new CustomerCreationException(e); } }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); var workstationId = _applicationSettings.WorkstationId; if (!workstationId.HasValue) { throw new InvalidWorkstationIdException(); } customer.WorkstationCreatedOn = workstationId.Value; _customerRepository.Save(customer); }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer( customerToCreate.FirstName, customerToCreate.LastName); customer.MailingAddress = _customerAddressBuilder.From(customerToCreate); if (customer.MailingAddress == null) { throw new InvalidCustomerMailingAddressException(); } _customerRepository.Save(customer); }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer( customerToCreate.FirstName, customerToCreate.LastName); customer.StatusLevel = _customerStatusFactory.CreateFrom(customerToCreate); if (customer.StatusLevel == CustomerStatus.Platinum) { _customerRepository.SaveSpecial(customer); } else { _customerRepository.Save(customer); } }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); MailingAddress mailingAddress; var mailingAddressSuccessfullyCreated = _mailingAddressFactory.TryParse( customerToCreate.Address, out mailingAddress); if (mailingAddress == null) { throw new InvalidMailingAddressException(); } customer.MailingAddress = mailingAddress; _customerRepository.Save(customer); }
public void an_exception_should_be_thrown_if_the_address_is_not_created() { //Arrange var customerToCreateDto = new CustomerToCreateDto { FirstName = "Bob", LastName = "Builder" }; var mockAddressBuilder = new Mock <ICustomerAddressBuilder>(); var mockCustomerRepository = new Mock <ICustomerRepository>(); mockAddressBuilder .Setup(x => x.From(It.IsAny <CustomerToCreateDto>())) .Returns(() => null); var customerService = new CustomerService( mockAddressBuilder.Object, mockCustomerRepository.Object); //Act & Assert Assert.That( () => customerService.Create(customerToCreateDto), Throws.TypeOf <InvalidCustomerMailingAddressException>() ); }
public async Task <IActionResult> CreateCustomer(CustomerToCreateDto customer) { var result = await Mediator.Send(new CreateCustomerCommand (customer)); return(HandleResult(result)); }
public void Create(CustomerToCreateDto customerToCreate) { var customer = new Customer(customerToCreate.Name); _customerRepository.Save(customer); }
private Customer BuildCustomerObjectFrom(CustomerToCreateDto customerToCreateDto) { return new Customer(customerToCreateDto.Name, customerToCreateDto.City); }
public void Create(CustomerToCreateDto customerToCreateDto) { var customer = BuildCustomerObjectFrom(customerToCreateDto); _customerRepository.Save(customer); }
public CreateCustomerCommand(CustomerToCreateDto customerToCreateDto) { CustomerToCreateDto = customerToCreateDto; }
private Customer BuildCustomerObjectFrom(CustomerToCreateDto customerToCreateDto) { return(new Customer(customerToCreateDto.Name, customerToCreateDto.City)); }
public void Create(CustomerToCreateDto customerToCreateDto) { var customer = new Customer(customerToCreateDto.Name, customerToCreateDto.City); _customerRepository.Save(customer); }