Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Functional Programming
Diskuy-Backend
Commits
2888589f
Commit
2888589f
authored
Jan 02, 2021
by
Muhammad Rafif Elfazri
Browse files
Change use get with get_by_name
parent
183056ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
diskuy_back/lib/diskuy_web/controllers/topic_controller.ex
View file @
2888589f
...
...
@@ -3,6 +3,7 @@ defmodule DiskuyWeb.TopicController do
alias
Diskuy
.
Forum
alias
Diskuy
.
Forum
.
Topic
alias
Diskuy
.
Utility
.
Utility
action_fallback
DiskuyWeb
.
FallbackController
...
...
@@ -21,12 +22,15 @@ defmodule DiskuyWeb.TopicController do
end
def
show
(
conn
,
%{
"id"
=>
id
})
do
topic
=
Forum
.
get_topic!
(
id
)
new_id
=
Utility
.
capitalize_string
(
id
)
topic
=
Forum
.
get_topic_by_name!
(
new_id
)
render
(
conn
,
"show.json"
,
topic:
topic
)
end
def
update
(
conn
,
%{
"id"
=>
id
,
"topic"
=>
topic_params
})
do
topic
=
Forum
.
get_topic!
(
id
)
new_id
=
Utility
.
capitalize_string
(
id
)
topic
=
Forum
.
get_topic_by_name!
(
new_id
)
with
{
:ok
,
%
Topic
{}
=
topic
}
<-
Forum
.
update_topic
(
topic
,
topic_params
)
do
render
(
conn
,
"show.json"
,
topic:
topic
)
...
...
@@ -34,7 +38,8 @@ defmodule DiskuyWeb.TopicController do
end
def
delete
(
conn
,
%{
"id"
=>
id
})
do
topic
=
Forum
.
get_topic!
(
id
)
new_id
=
Utility
.
capitalize_string
(
id
)
topic
=
Forum
.
get_topic_by_name!
(
new_id
)
with
{
:ok
,
%
Topic
{}}
<-
Forum
.
delete_topic
(
topic
)
do
send_resp
(
conn
,
:no_content
,
""
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment