public async Task <IActionResult> Create([FromBody] CustomerCreateContract customerCreateContract) { var command = new CreateCustomerCommand(customerCreateContract); var result = await _mediator.Send(command); return(Ok(result)); }
public async Task <Customer> Create(CustomerCreateContract customerCreateContract) { var newCustomer = new Customer { Name = customerCreateContract.Name }; try { await _context.Customers.AddAsync(newCustomer); await _context.SaveChangesAsync(); return(await GetByIdInternal(newCustomer.Id)); } catch (DbUpdateException ex) { throw new DomainException("An error occured during customer creation", ex); } }
public CreateCustomerCommand(CustomerCreateContract customerCreateContract) { CustomerCreateContract = customerCreateContract; }