Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove :register APIs for student and teacher #151

Merged
merged 8 commits into from
Feb 23, 2024

Conversation

sudheshna-donthineni
Copy link
Contributor

@sudheshna-donthineni sudheshna-donthineni commented Feb 16, 2024

Now, db-service handles the creation of a new student/teacher. It first checks if the student/teacher already exists, if yes, then updates the student/teacher (along with user), otherwise creates a student/teacher (along with user).
Since student and teacher are coupled with user, any updating of student and teacher should also update the user.

@sudheshna-donthineni sudheshna-donthineni changed the title student/register API also checks if student id exists Remove :register APIs for student and teacher Feb 16, 2024
@Bahugunajii Bahugunajii self-requested a review February 16, 2024 07:24
Copy link
Member

@Bahugunajii Bahugunajii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, for update and delete functions, we will be using update_student_with_user and delete_student_with_user.

Let's make these slight changes!

@sudheshna-donthineni
Copy link
Contributor Author

Similarly, for update and delete functions, we will be using update_student_with_user and delete_student_with_user.

Let's make these slight changes!

update_student_with_user is already implemented. We technically don't want to have deletion functionality.

@Bahugunajii
Copy link
Member

Bahugunajii commented Feb 23, 2024

Similarly, for update and delete functions, we will be using update_student_with_user and delete_student_with_user.
Let's make these slight changes!

update_student_with_user is already implemented. We technically don't want to have deletion functionality.

What I'm trying to say is, we have a PATCH /student API and the fucntion definition looks like:

  def update(conn, params) do
    student = Users.get_student!(params["id"])

    with {:ok, %Student{} = student} <- Users.update_student(student, params) do
      render(conn, "show.json", student: student)
    end
  end

So instead of updating only the student here, we can change it to update student along with the user!

@sudheshna-donthineni sudheshna-donthineni merged commit 96bd918 into main Feb 23, 2024
3 checks passed
@sudheshna-donthineni sudheshna-donthineni deleted the student-register branch February 23, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants