def post(self, request): serializer = AppointmentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def put(self, request, pk): doctor = self.get_object(pk) serializer = AppointmentSerializer(instance=doctor, data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def post(self, request): serializer = AppointmentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def get(self, request, pk): doctor = self.get_object(pk) serializer = AppointmentSerializer(doctor) return Response(serializer.data)
def get(self, request): doctorList = Appointment.objects.filter(user=self.user) serializer = AppointmentSerializer(doctorList, many=True) return Response(serializer.data, status=status.HTTP_200_OK)
def get(self, request): appointment_list = Appointment.objects.all() serializer = AppointmentSerializer(appointment_list, many=True) return Response(serializer.data, status=status.HTTP_200_OK)