get("/",
summary("Gets products for criteria"),
nickname("products"),
responseClass("List[ProductListItemDto]"),
notes("Additional notes")) {
// Is there any way to extract this automatically to a case class?
val containsText = params get "containsText"
val maxPrice = params get "maxPrice" map (_.toDouble)
val orderBy = (params get "orderBy" map (mapSearchOrder(_))).getOrElse(ProductSearchOrder.Name)
val ascending = params get "ascending" map (_.toBoolean) getOrElse true
val pageNumber = params get "pageNumber" map (_.toInt) getOrElse 1
val itemsPerPage = params get "itemsPerPage" map (_.toInt) getOrElse (10)
val criteria = ProductSearchCriteria(containsText, maxPrice, orderBy, ascending, pageNumber, itemsPerPage)
env.productFinder.findProducts(criteria)
}