Esempio n. 1
0
 def retrieve(self, request, pk=None):
     queryset = Customer.objects.all()
     customer = get_object_or_404(queryset, pk=pk)
     serializer = CustomerSerializer(customer,
                                     context={"request": "request"})
     return Response({
         "error": False,
         "message": "single Data Fetch",
         "data": serializer.data
     })
Esempio n. 2
0
 def list(self, request):
     bill = Bill.objects.all()
     serializer = CustomerSerializer(bill,
                                     many=True,
                                     context={"request": request})
     response_dict = {
         "error": False,
         "message": "All Bill List Data",
         "data": serializer.data
     }
     return Response(response_dict)
Esempio n. 3
0
 def update(self, request, pk=None):
     queryset = CustomerRequest.objects.all()
     customer_request = get_object_or_404(queryset, pk=pk)
     serializer = CustomerSerializer(customer_request,
                                     data=request.data,
                                     context={"request": request})
     serializer.is_valid()
     serializer.save()
     return Response({"error": False, "message": "Update Successful"})
Esempio n. 4
0
 def create(self, request):
     try:
         serializer = CustomerSerializer(data=request.data,
                                         context={"request": request})
         serializer.is_valid(raise_exception=True)
         serializer.save()
         dict_response = {
             "error": False,
             "message": "Request Data Save Successful"
         }
     except:
         dict_response = {
             "error": True,
             "message": "Error While Trying to Save Request Data"
         }
     return Response(dict_response)