Search in sources :

Example 1 with ConflictException

use of core.framework.web.exception.ConflictException in project core-ng-demo-project by neowu.

the class CustomerService method create.

public CustomerView create(CreateCustomerRequest request) {
    Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
    if (existingCustomer.isPresent()) {
        throw new ConflictException("customer already exists, email=" + request.email);
    }
    Customer customer = new Customer();
    customer.email = request.email;
    customer.firstName = request.firstName;
    customer.lastName = request.lastName;
    customer.updatedTime = LocalDateTime.now();
    customer.id = customerRepository.insert(customer).get();
    return view(customer);
}
Also used : Customer(app.demo.customer.domain.Customer) ConflictException(core.framework.web.exception.ConflictException)

Aggregations

Customer (app.demo.customer.domain.Customer)1 ConflictException (core.framework.web.exception.ConflictException)1