12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- defmodule GiomWeb.StocktransController do
- use GiomWeb, :controller
- alias Giom.Accounting
- alias Giom.Accounting.Stocktrans
- def index(conn, _params) do
- stocktrans = Accounting.list_stocktrans()
- render(conn, "index.html", stocktrans: stocktrans)
- end
- def new(conn, _params) do
- changeset = Accounting.change_stocktrans(%Stocktrans{})
- render(conn, "new.html", changeset: changeset)
- end
- def create(conn, %{"stocktrans" => stocktrans_params}) do
- case Accounting.create_stocktrans(stocktrans_params) do
- {:ok, stocktrans} ->
- conn
- |> put_flash(:info, "Stocktrans created successfully.")
- |> redirect(to: stocktrans_path(conn, :show, stocktrans))
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "new.html", changeset: changeset)
- end
- end
- def show(conn, %{"id" => id}) do
- stocktrans = Accounting.get_stocktrans!(id)
- render(conn, "show.html", stocktrans: stocktrans)
- end
- def edit(conn, %{"id" => id}) do
- stocktrans = Accounting.get_stocktrans!(id)
- changeset = Accounting.change_stocktrans(stocktrans)
- render(conn, "edit.html", stocktrans: stocktrans, changeset: changeset)
- end
- def update(conn, %{"id" => id, "stocktrans" => stocktrans_params}) do
- stocktrans = Accounting.get_stocktrans!(id)
- case Accounting.update_stocktrans(stocktrans, stocktrans_params) do
- {:ok, stocktrans} ->
- conn
- |> put_flash(:info, "Stocktrans updated successfully.")
- |> redirect(to: stocktrans_path(conn, :show, stocktrans))
- {:error, %Ecto.Changeset{} = changeset} ->
- render(conn, "edit.html", stocktrans: stocktrans, changeset: changeset)
- end
- end
- def delete(conn, %{"id" => id}) do
- stocktrans = Accounting.get_stocktrans!(id)
- {:ok, _stocktrans} = Accounting.delete_stocktrans(stocktrans)
- conn
- |> put_flash(:info, "Stocktrans deleted successfully.")
- |> redirect(to: stocktrans_path(conn, :index))
- end
- end
|