public ResponseMessage ProcessOrder(RequestMessage reqMsg) { ResponseMessage responseToDuplicateMessage = _deduplicator.GetExistingResponseMessage(reqMsg.RequestId); if (responseToDuplicateMessage != null) { return(responseToDuplicateMessage); } ResponseMessage response; switch (reqMsg.Operation) { case CreateOrderOperation.Id: CreateOrderOperation submitOrder = new CreateOrderOperation { InventoryRepository = _InventoryRepository, OrderRepository = _orderRepository }; response = submitOrder.ExecuteOperation(reqMsg); break; case CancelOrderOperation.Id: CancelOrderOperation cancelOrder = new CancelOrderOperation { InventoryRepository = _InventoryRepository, OrderRepository = _orderRepository }; response = cancelOrder.ExecuteOperation(reqMsg); break; case GetOrderOperation.Id: GetOrderOperation getOrder = new GetOrderOperation { OrderRepository = _orderRepository }; response = getOrder.ExecuteOperation(reqMsg); break; default: _loggerService.WriteLine("Received bad message: " + reqMsg.RequestId, "ProcessOrderError"); response = _responseMessageFactory.CreateBadRequestResponseMessage(reqMsg); break; } _deduplicator.StoreResponseToMessage(reqMsg.RequestId, response); return(response); }