Skip to content

Commit

Permalink
Add module to create supply
Browse files Browse the repository at this point in the history
  • Loading branch information
erickmp07 committed Oct 20, 2021
1 parent d5463b7 commit 0280c12
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/inmana/supplies/create.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Inmana.Supplies.Create do
alias Inmana.{Repo, Supply}

def call(params) do
params
|> Supply.changeset()
|> Repo.insert()
|> handle_insert()
end

defp handle_insert({:ok, %Supply{}} = result), do: result

defp handle_insert({:error, result}), do: {:error, %{result: result, status: :bad_request}}
end

0 comments on commit 0280c12

Please sign in to comment.