Files
phoenix-ausblick/lib/outlook_web/controllers/artikel_controller.ex
2023-02-14 21:02:48 +01:00

21 lines
564 B
Elixir

defmodule OutlookWeb.ArtikelController do
use OutlookWeb, :controller
alias Outlook.Artikel
def index(conn, _params) do
artikel = Artikel.list_artikel()
render(conn, :index, artikel: artikel, page_title: "Artikel")
end
def show(conn, %{"tid" => tid} = params) do
case Artikel.get_artikel_by_tid(tid) do
{:ok, artikel} -> render(conn, :show, artikel: artikel, page_title: artikel.title)
{:error, message} -> conn
|> put_status(404)
|> render(OutlookWeb.ErrorHTML, "404.html")
|> halt()
end
end
end