Files
BeetRoundServer/lib/beet_round_server/bidding_rounds.ex

105 lines
2.1 KiB
Elixir

defmodule BeetRoundServer.BiddingRounds do
@moduledoc """
The BiddingRounds context.
"""
import Ecto.Query, warn: false
alias BeetRoundServer.Repo
alias BeetRoundServer.BiddingRounds.BiddingRound
@doc """
Returns the list of bidding_rounds.
## Examples
iex> list_bidding_rounds()
[%BiddingRound{}, ...]
"""
def list_bidding_rounds do
Repo.all(BiddingRound)
end
@doc """
Gets a single bidding_round.
Raises `Ecto.NoResultsError` if the Bidding round does not exist.
## Examples
iex> get_bidding_round!(123)
%BiddingRound{}
iex> get_bidding_round!(456)
** (Ecto.NoResultsError)
"""
def get_bidding_round!(id), do: Repo.get!(BiddingRound, id)
@doc """
Creates a bidding_round.
## Examples
iex> create_bidding_round(%{field: value})
{:ok, %BiddingRound{}}
iex> create_bidding_round(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_bidding_round(attrs) do
%BiddingRound{}
|> BiddingRound.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a bidding_round.
## Examples
iex> update_bidding_round(bidding_round, %{field: new_value})
{:ok, %BiddingRound{}}
iex> update_bidding_round(bidding_round, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_bidding_round(%BiddingRound{} = bidding_round, attrs) do
bidding_round
|> BiddingRound.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a bidding_round.
## Examples
iex> delete_bidding_round(bidding_round)
{:ok, %BiddingRound{}}
iex> delete_bidding_round(bidding_round)
{:error, %Ecto.Changeset{}}
"""
def delete_bidding_round(%BiddingRound{} = bidding_round) do
Repo.delete(bidding_round)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking bidding_round changes.
## Examples
iex> change_bidding_round(bidding_round)
%Ecto.Changeset{data: %BiddingRound{}}
"""
def change_bidding_round(%BiddingRound{} = bidding_round, attrs \\ %{}) do
BiddingRound.changeset(bidding_round, attrs)
end
end