Skip to content

Instantly share code, notes, and snippets.

@godrm
Created May 2, 2019 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godrm/b1fa9660a0df0c3799678545e7080f41 to your computer and use it in GitHub Desktop.
Save godrm/b1fa9660a0df0c3799678545e7080f41 to your computer and use it in GitHub Desktop.
class CustomOrderRequest {
private (set) var products = [Product]()
}
protocol OrderCommand {
//
}
protocol OrderManagerProtocol {
func send(command : OrderCommand)
}
class AddCustomerOrderCommand : OrderCommand {
private var id : UUID
private var products = [Product]()
init(id: UUID, products: [Product]) {
self.id = id
self.products.append(contentsOf: products)
}
}
class CustomerOrderController {
private (set) var orderManager : OrderManagerProtocol
init(manager: OrderManagerProtocol) {
self.orderManager = manager
}
func addCustomerOrderCommand(customerId : UUID, request: CustomOrderRequest) {
orderManager.send(command: AddCustomerOrderCommand(id: customerId, products: request.products))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment