Add all
This commit is contained in:
parent
b35e18cd20
commit
82f55f7afe
80 changed files with 6687 additions and 5 deletions
45
lib/nulla_web/controllers/media_attachment_controller.ex
Normal file
45
lib/nulla_web/controllers/media_attachment_controller.ex
Normal file
|
@ -0,0 +1,45 @@
|
|||
defmodule NullaWeb.MediaAttachmentController do
|
||||
use NullaWeb, :controller
|
||||
|
||||
alias Nulla.MediaAttachments
|
||||
alias Nulla.MediaAttachments.MediaAttachment
|
||||
|
||||
action_fallback NullaWeb.FallbackController
|
||||
|
||||
def index(conn, _params) do
|
||||
media_attachments = MediaAttachments.list_media_attachments()
|
||||
render(conn, :index, media_attachments: media_attachments)
|
||||
end
|
||||
|
||||
def create(conn, %{"media_attachment" => media_attachment_params}) do
|
||||
with {:ok, %MediaAttachment{} = media_attachment} <-
|
||||
MediaAttachments.create_media_attachment(media_attachment_params) do
|
||||
conn
|
||||
|> put_status(:created)
|
||||
|> put_resp_header("location", ~p"/api/media_attachments/#{media_attachment}")
|
||||
|> render(:show, media_attachment: media_attachment)
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
media_attachment = MediaAttachments.get_media_attachment!(id)
|
||||
render(conn, :show, media_attachment: media_attachment)
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "media_attachment" => media_attachment_params}) do
|
||||
media_attachment = MediaAttachments.get_media_attachment!(id)
|
||||
|
||||
with {:ok, %MediaAttachment{} = media_attachment} <-
|
||||
MediaAttachments.update_media_attachment(media_attachment, media_attachment_params) do
|
||||
render(conn, :show, media_attachment: media_attachment)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
media_attachment = MediaAttachments.get_media_attachment!(id)
|
||||
|
||||
with {:ok, %MediaAttachment{}} <- MediaAttachments.delete_media_attachment(media_attachment) do
|
||||
send_resp(conn, :no_content, "")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue