def post(self, request):
     data = request.POST
     try:
         walletid = int(data.get("id"))
         wallet = Wallet.objects(WalletID=walletid)
         if str(request.user) == str(wallet[0].user):
             amount2 = float(data.get("amount"))
             wallet = Wallet._get_collection().find_and_modify(
                 query={
                     'WalletID': walletid,
                     'amount': {
                         '$gte': amount2
                     }
                 },
                 update={'$inc': {
                     'amount': amount2 * -1
                 }},
                 new=True)
             if wallet is not None:
                 Transaction(transType='Decharge',
                             fwalletid=walletid,
                             amount=amount2).save()
                 return JsonResponse({"Decharged": str(amount2)},
                                     safe=False)
             else:
                 return JsonResponse({"error": "Not sufficient value"},
                                     safe=False)
         else:
             return JsonResponse({"error": "Not allowed"}, safe=False)
     except:
         return JsonResponse({"error": "not a valid data"}, safe=False)
 def post(self, request):
     data = request.POST
     try:
         sourceWallId = int(data.get("Sourceid"))
         destWallId = int(data.get("Destid"))
         if str(request.user) == str(sourceWallet[0].user):
             amount2 = float(data.get("amount"))
             wallet = Wallet._get_collection().find_and_modify(
                 query={
                     'WalletID': sourceWallId,
                     'amount': {
                         '$gte': amount2
                     }
                 },
                 update={'$inc': {
                     'amount': amount2 * -1
                 }},
                 new=True)
             if wallet is not None:
                 wallet1 = Wallet._get_collection().find_and_modify(
                     query={'WalletID': destWallId},
                     update={'$inc': {
                         'amount': amount2
                     }},
                     new=True)
                 Transaction(transType='Transfer',
                             fwalletid=sourceWallId,
                             swalletid=destWallId,
                             amount=amount2).save()
                 Transaction(transType='Charge',
                             fwalletid=destWallId,
                             amount=amount2).save()
                 return JsonResponse({"Transfered": str(amount2)},
                                     safe=False)
             else:
                 return JsonResponse({"error": "Not enough value"},
                                     safe=False)
         else:
             return JsonResponse({"error": "Not allowed"}, safe=False)
     except:
         return JsonResponse({"error": "not a valid data"}, safe=False)