API can serve bidding_of_highest_round and biddings_of_round/:round_number route.
This commit is contained in:
@ -2,6 +2,7 @@ defmodule BeetRoundServerWeb.BiddingController do
|
||||
use BeetRoundServerWeb, :controller
|
||||
|
||||
alias BeetRoundServer.Biddings
|
||||
alias BeetRoundServer.BiddingRounds.BiddingRoundFacade
|
||||
# alias BeetRoundServer.Biddings.Bidding
|
||||
|
||||
action_fallback BeetRoundServerWeb.FallbackController
|
||||
@ -13,6 +14,19 @@ defmodule BeetRoundServerWeb.BiddingController do
|
||||
render(conn, :index, biddings: biddings)
|
||||
end
|
||||
|
||||
def biddings_of_round(conn, %{"round_number" => round_number}) do
|
||||
biddings = Biddings.biddings_of_round(round_number)
|
||||
render(conn, :index, biddings: biddings)
|
||||
end
|
||||
|
||||
def biddings_of_highest_round(conn, _params) do
|
||||
round = BiddingRoundFacade.get_highest_bidding_round()
|
||||
IO.puts("Highest round number:")
|
||||
IO.puts(round.round_number)
|
||||
biddings = Biddings.biddings_of_round(round.round_number)
|
||||
render(conn, :index, biddings: biddings)
|
||||
end
|
||||
|
||||
# def create(conn, %{"bidding" => bidding_params}) do
|
||||
# with {:ok, %Bidding{} = bidding} <- Biddings.create_bidding(bidding_params) do
|
||||
# conn
|
||||
|
||||
@ -33,8 +33,11 @@ defmodule BeetRoundServerWeb.Router do
|
||||
get "/bidding_rounds/start_new", BiddingRoundController, :start_new
|
||||
get "/bidding_rounds/restart", BiddingRoundController, :restart
|
||||
get "/bidding_rounds/stop", BiddingRoundController, :stop
|
||||
|
||||
get "/biddings_of_round/:round_number", BiddingController, :biddings_of_round
|
||||
get "/biddings_of_highest_round", BiddingController, :biddings_of_highest_round
|
||||
|
||||
resources "/users", UserController, except: [:new, :edit]
|
||||
resources "/biddings", BiddingController, except: [:new, :edit]
|
||||
end
|
||||
|
||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||
|
||||
Reference in New Issue
Block a user