22 lines
584 B
Elixir
22 lines
584 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)
|
|
|> put_view(OutlookWeb.ErrorHTML)
|
|
|> render("404.html")
|
|
|> halt()
|
|
end
|
|
end
|
|
end
|