-
-
Save shankardevy/98ba3dd5a8a5c15118a0b8ca5d73cf7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MangoWeb.RegistrationController do | |
use MangoWeb, :controller | |
alias Mango.CRM | |
def new(conn, _) do | |
changeset = CRM.build_customer() | |
render(conn, "new.html", changeset: changeset) | |
end | |
def create(conn, %{"registration" => registration_params}) do | |
case CRM.create_customer(registration_params) do | |
{:ok, _customer} -> | |
conn | |
|> put_flash(:info, "Registration successful") | |
|> redirect(to: page_path(conn, :index)) | |
{:error, changeset} -> | |
conn | |
|> render(:new, changeset: changeset) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment