44 lines
1.4 KiB
Elixir
44 lines
1.4 KiB
Elixir
defmodule BeetRoundServerWeb.BiddingRoundController do
|
|
use BeetRoundServerWeb, :controller
|
|
|
|
alias BeetRoundServer.BiddingRounds
|
|
alias BeetRoundServer.BiddingRounds.BiddingRound
|
|
|
|
action_fallback BeetRoundServerWeb.FallbackController
|
|
|
|
def index(conn, _params) do
|
|
bidding_rounds = BiddingRounds.list_bidding_rounds()
|
|
render(conn, :index, bidding_rounds: bidding_rounds)
|
|
end
|
|
|
|
def create(conn, %{"bidding_round" => bidding_round_params}) do
|
|
with {:ok, %BiddingRound{} = bidding_round} <- BiddingRounds.create_bidding_round(bidding_round_params) do
|
|
conn
|
|
|> put_status(:created)
|
|
|> put_resp_header("location", ~p"/api/bidding_rounds/#{bidding_round}")
|
|
|> render(:show, bidding_round: bidding_round)
|
|
end
|
|
end
|
|
|
|
def show(conn, %{"id" => id}) do
|
|
bidding_round = BiddingRounds.get_bidding_round!(id)
|
|
render(conn, :show, bidding_round: bidding_round)
|
|
end
|
|
|
|
def update(conn, %{"id" => id, "bidding_round" => bidding_round_params}) do
|
|
bidding_round = BiddingRounds.get_bidding_round!(id)
|
|
|
|
with {:ok, %BiddingRound{} = bidding_round} <- BiddingRounds.update_bidding_round(bidding_round, bidding_round_params) do
|
|
render(conn, :show, bidding_round: bidding_round)
|
|
end
|
|
end
|
|
|
|
def delete(conn, %{"id" => id}) do
|
|
bidding_round = BiddingRounds.get_bidding_round!(id)
|
|
|
|
with {:ok, %BiddingRound{}} <- BiddingRounds.delete_bidding_round(bidding_round) do
|
|
send_resp(conn, :no_content, "")
|
|
end
|
|
end
|
|
end
|