params.valid? if cart_repo.item_exist?(params[:item]) item = CartItemRepository.new.create_copy(params[:item]) else item = CartItemRepository.new.create(params[:item]) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
params.valid? event_store.apply(Order::Events::ItemAdded.new(payload)) if cart_repo.item_exist?(params[:item]) item = CartItemRepository.new.create_copy(params[:item]) else item = CartItemRepository.new.create(params[:item]) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
params.valid? event_store.apply(Orders::Events::ItemAdded.new(payload)) if cart_repo.item_exist?(params[:item]) item = CartItemRepository.new.create_copy(params[:item]) else item = CartItemRepository.new.create(params[:item]) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
params.valid? events = event_store.get_stream(params[:order_id]) items = @project.call(Order::Projections::ItemList, events) if items.include?(params[:item]) event_store.apply(Orders::Events::ItemAdded.new(payload)) else event_store.apply(Orders::Events::CoppyItemAdded.new(payload)) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
params.valid? events = event_store.get_stream(params[:order_id]) items = @project.call(Order::Projections::ItemList, events, {}) if items.include?(params[:item]) event_store.apply(Orders::Events::ItemAdded.new(payload)) else event_store.apply(Orders::Events::CoppyItemAdded.new(payload)) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
params.valid? events = event_store.get_stream(params[:order_id]) items = @project.call(Order::Projections::ItemList, events, {}) if items.include?(params[:item]) event_store.apply(Orders::Events::ItemAdded.new(payload)) else event_store.apply(Orders::Events::CoppyItemAdded.new(payload)) end analytics.call('Item Added') redirect_to routes.order_path(params[:order_id]) end end end
event_store.subscribe(Orders::Events::CoppyItemAdded) do |event| analytics.call(‘Copy of item added’, event.payload) end event_store.subscribe(Orders::Events::ItemRemoved) do |event| analytics.call(‘Item removed', event.payload) end
params.valid? events = event_store.get_stream(params[:order_id]) items = @project.call(Order::Projections::ItemList, events, {}) if items.include?(params[:item]) event_store.apply(Orders::Events::ItemAdded.new(payload)) else event_store.apply(Orders::Events::CoppyItemAdded.new(payload)) end redirect_to routes.order_path(params[:order_id]) end end end