SHARE
TWEET

Untitled

a guest Jan 12th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def put_me(conn,%{"surname" => surname, "given_name" => given_name, "birthday" => birthday,
  2.                     "address" => address, "phone" => phone, "email" => email, "gender" => gender}) do
  3.     user = get_user(conn)
  4.     check_member(user,conn)
  5.     changeset = User.update_mindoula_changeset(user, %{"first_name" => given_name, "last_name"=> surname,
  6.                                                        "date_of_birth"=> birthday, "gender" => gender,
  7.                                                        "address" => address, "phone" => String.replace(phone, "-", ""),
  8.                                                        "gender" => gender, "email" => email})
  9.     case Repo.update(changeset) do
  10.       {:ok, user} ->
  11.         json conn, %{
  12.           "status" => "OK",
  13.           "data" => basic_info_user(user)}
  14.       {:error, changeset} ->
  15.         Response.error(conn, %{"status"=> Constants.validation_failed,
  16.                                "message"=> Constants.validation_failed_message,
  17.                                "fields"=> convertErrorsToFields(changeset.errors)})
  18.     end
  19.   end
RAW Paste Data
Top