                
            }
         }
+        */
+    }
+    func updateSpot(currentbid : Bid, status :Int,  sender: UIButton!)-> Void
+    {
+        let prefQuery = PFQuery(className: "Spot")
+        prefQuery.getObjectInBackgroundWithId(DetailSpot.spotId){
+            (prefObj: PFObject?, error: NSError?) -> Void in
+            if error != nil {
+                self.showmessage("Error on Acceped bid")
+                print(error)
+                
+            } else if let prefObj = prefObj {
+                prefObj["StatusId"] = status
+                if(status == 2) //Accepted
+                {
+                    prefObj["AcctepedBidId"] = currentbid.bidId
+                }
+                prefObj.saveInBackgroundWithTarget(sender, selector: nil)
+                self.showmessage("Successfully Acceped bid")
+                
+            }
+        }
+    }
+    func updateBid(currentbid : Bid, status :Int,  sender: UIButton!)-> Void
+    {
+        let prefQuery = PFQuery(className: "Bid")
+        prefQuery.getObjectInBackgroundWithId(currentbid.bidId){
+            (prefObj: PFObject?, error: NSError?) -> Void in
+            if error != nil {
+                //self.showmessage("Error on Acceped bid")
+                print(error)
+            } else if let prefObj = prefObj {
+                prefObj["StatusId"] = status
+                prefObj.saveInBackgroundWithTarget(sender, selector: nil)
+                //self.showmessage("Successfully Acceped bid")
+                
+            }
+        }
     }
     
         func showmessage ( msg : String) -> Void

                
            }
        }

    }
    func btnReject_click(sender: UIButton!) {
        let currentbid : Bid = datas[sender.tag]
        print("btnReject_click  from main at  " + String(sender.tag) + "  value: " + String(currentbid.value))
        var prefQuery = PFQuery(className: "Spot")
        prefQuery.getObjectInBackgroundWithId(DetailSpot.spotId){
            (prefObj: PFObject?, error: NSError?) -> Void in
            if error != nil {

       
        let currentbid : Bid = datas[sender.tag]
        print("btnAccept_click from main  at " + String(sender.tag) + "  value: " + String(currentbid.value))
         self.updateBid(currentbid, status :2,  sender: sender!)
         self.updateSpot(currentbid, status :2,  sender: sender!)
        self.tableView.reloadData()
       /*
        let prefQuery = PFQuery(className: "Spot")
        prefQuery.getObjectInBackgroundWithId(DetailSpot.spotId){
            (prefObj: PFObject?, error: NSError?) -> Void in
