-
-
Save shankardevy/e0379f63de933cd4ee8bbe8dab80ec38 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() | |
residence_areas = Auroville.ResidenceService.list_areas | |
render(conn, "new.html", changeset: changeset, residence_areas: residence_areas) | |
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} -> | |
residence_areas = Auroville.ResidenceService.list_areas | |
conn | |
|> render(:new, changeset: changeset, residence_areas: residence_areas) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment