App.ProductCategoriesController = Ember.Controller.extend
  #needs: ['table']
  actions:
    addProduct: (product)->
      if table_route = App.Router.router.currentHandlerInfos.find((r) -> r.name == 'table')
        table = table_route.context
        if existing = @store.all('product_order').find((po)->po.get('table') == table and po.get('product') == product)
          existing.increment()
        else
          @store.createRecord 'product_order', table: table, product: product
      else
        alert "Please select a table first"
