def retrieve(self, request, pk=None):
     queryset = CompanyBank.objects.all()
     companybank = get_object_or_404(queryset, pk=pk)
     serializer = CompanyBankSerializer(companybank,
                                        context={"request": request})
     return Response({
         "error": False,
         "message": "Single Data Fetch",
         "data": serializer.data
     })
 def list(self, request):
     companybank = CompanyBank.objects.all()
     serializer = CompanyBankSerializer(companybank,
                                        many=True,
                                        context={"request": request})
     response_dict = {
         "error": False,
         "message": "All Company Bank List Data",
         "data": serializer.data
     }
     return Response(response_dict)
Beispiel #3
0
    def retrieve(self, request, pk=None):
        queryset = Company.objects.all()
        company = get_object_or_404(queryset, pk=pk)
        serializer = CompanySerliazer(company, context={"request": request})

        serializer_data = serializer.data
        # Accessing All the Medicine Details of Current Medicine ID
        company_bank_details = CompanyBank.objects.filter(company_id=serializer_data["id"])
        companybank_details_serializers = CompanyBankSerializer(company_bank_details, many=True)
        serializer_data["company_bank"] = companybank_details_serializers.data

        return Response({"error": False, "message": "Single Data Fetch", "data": serializer_data})
Beispiel #4
0
 def update(self,request,pk=None):
     queryset=CompanyBank.objects.all()
     companybank=get_object_or_404(queryset,pk=pk)
     serializer=CompanyBankSerializer(companybank,data=request.data,context={"request":request})
     serializer.is_valid()
     serializer.save()
     return Response({"error":False,"message":"Data Has Been Updated"})
    def update(self, request, pk=None):
        try:
            queryset = CompanyBank.objects.all()
            companybank = get_object_or_404(queryset, pk=pk)
            serializer = CompanyBankSerializer(companybank,
                                               data=request.data,
                                               context={"request": request})
            serializer.is_valid(raise_exception=True)
            serializer.save()
            dict_response = {
                "error": False,
                "message": "Company bank data updated",
            }
        except Exception as e:
            print('Company bank update', e)
            dict_response = {
                "error": True,
                "message": "Company bank data updation error",
            }
        return Response(dict_response)


# company_list=CompanyViewSet.as_view({"get": "list"})
# company_create=CompanyViewSet.as_view({"post": "list"})
# company_update=CompanyViewSet.as_view({"put": "update"})
Beispiel #6
0
 def create(self,request):
     try:
         serializer=CompanyBankSerializer(data=request.data,context={"request":request})
         serializer.is_valid(raise_exception=True)
         serializer.save()
         dict_response={"error":False,"message":"Company Bank Data Save Successfully"}
     except:
         dict_response={"error":True,"message":"Error During Saving Company Bank Data"}
     return Response(dict_response)
Beispiel #7
0
 def create(self, request):
     try:
         serializer = CompanyBankSerializer(data=request.data,
                                            context={"request": request})
         serializer.is_valid(raise_exception=True)
         serializer.save()
         response_dict = {
             "error": False,
             "message": "Company bank data save successfully"
         }
     except:
         response_dict = {
             "error": True,
             "message": "Error during saving company bank data"
         }
     return Response(response_dict)
 def create(self, request):
     try:
         serializer = CompanyBankSerializer(data=request.data,
                                            context={"request": request})
         serializer.is_valid(raise_exception=True)
         serializer.save()
         dict_response = {
             "error": False,
             "message": "Company Bank data created",
         }
     except Exception as e:
         print('Company bank create', e)
         dict_response = {
             "error": True,
             "message": "Company Bank data creation error",
         }
     return Response(dict_response, status=status.HTTP_201_CREATED)
Beispiel #9
0
    def update(self, request, pk=None):
        try:
            queryset = CompanyBank.objects.all()
            companybank = get_object_or_404(queryset, pk=pk)
            serializer = CompanyBankSerializer(companybank,
                                               data=request.data,
                                               context={"request": request})
            serializer.is_valid(raise_exception=True)
            serializer.save()
            response_dict = {
                "error": True,
                "message": "Successfully updated company bank data"
            }
        except:
            response_dict = {
                "error": True,
                "message": "Error during updating company bank data"
            }

        return Response(response_dict)