Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "id_Bonding,Type_Linkage,hour_Start,hours_End,Status")] Bonding bonding)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bonding).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bonding));
 }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "id_Bonding,Type_Linkage,hour_Start,hours_End,Status")] Bonding bonding)
        {
            if (ModelState.IsValid)
            {
                db.Bondings.Add(bonding);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bonding));
        }
Exemplo n.º 3
0
        // GET: Bondings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bonding bonding = db.Bondings.Find(id);

            if (bonding == null)
            {
                return(HttpNotFound());
            }
            return(View(bonding));
        }
Exemplo n.º 4
0
        public override void OnReceive(Context context, Intent intent)
        {
            string action = intent.Action;

            switch (action)
            {
            case BluetoothDevice.ActionFound:
            {
                BluetoothDevice device      = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
                BluetoothClass  deviceClass = (BluetoothClass)intent.GetParcelableExtra(BluetoothDevice.ExtraClass);

                // only interested in devices not already paired
                if (device.BondState == Bond.None)
                {
                    if (_fragment != null)
                    {
                        _fragment.OnDeviceFound(device, deviceClass);
                    }
                    else if (_activity != null)
                    {
                        _activity.OnDeviceFound(device, deviceClass);
                    }
                }
            }
            break;

            case BluetoothAdapter.ActionDiscoveryStarted:
            {
                if (_fragment != null)
                {
                    _fragment.OnScanStarted();
                }
                else if (_activity != null)
                {
                    _activity.OnScanStarted();
                }
            }
            break;

            case BluetoothAdapter.ActionDiscoveryFinished:
            {
                if (_fragment != null)
                {
                    _fragment.OnScanComplete();
                }
                else if (_activity != null)
                {
                    _activity.OnScanComplete();
                }
            }
            break;

            case BluetoothAdapter.ActionRequestDiscoverable:
            {
                //if (mFragment != null)
                //    mFragment.OnScanComplete();
                //((BluetoothUtilsActivity)mActivity).OnScanComplete();
            }
            break;

            case BluetoothDevice.ActionPairingRequest:
            {
                BluetoothDevice device      = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
                BluetoothClass  deviceClass = (BluetoothClass)intent.GetParcelableExtra(BluetoothDevice.ExtraClass);

                //_fragment.OnPairDevice(device, (int)Bond.None);
            }
            break;

            case BluetoothDevice.ActionBondStateChanged:
            {
                Bonding         state     = (Bonding)intent.GetIntExtra(BluetoothDevice.ExtraBondState, BluetoothDevice.Error);
                Bonding         prevState = (Bonding)intent.GetIntExtra(BluetoothDevice.ExtraPreviousBondState, BluetoothDevice.Error);
                BluetoothDevice device    = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);

                // device has successfully paired
                if (state == Bonding.Bonded && prevState == Bonding.Bonding)
                {
                    if (_fragment != null)
                    {
                        _fragment.OnPairDevice(device, (int)state);
                    }
                    else if (_activity != null)
                    {
                        _activity.OnPairDevice(device, (int)state);
                    }
                    return;
                }

                // device has successfully unpaired
                if (state == Bonding.None && prevState == Bonding.Bonded)
                {
                    if (_fragment != null)
                    {
                        _fragment.OnPairDevice(device, (int)state);
                    }
                    else if (_activity != null)
                    {
                        _activity.OnPairDevice(device, (int)state);
                    }
                    return;
                }

                // device pairing was cancelled
                if (state == Bonding.None && prevState == Bonding.Bonding)
                {
                    if (_fragment != null)
                    {
                        _fragment.OnPairDevice(device, (int)Bonding.Cancelled);
                    }
                    else if (_activity != null)
                    {
                        _activity.OnPairDevice(device, (int)Bonding.Cancelled);
                    }
                    return;
                }

                if (state == Bonding.None && prevState == Bonding.None)
                {
                    if (_fragment != null)
                    {
                        _fragment.OnPairDevice(device, (int)state);
                    }
                    else if (_activity != null)
                    {
                        _activity.OnPairDevice(device, (int)state);
                    }
                    return;
                }
            }
            break;

            default:
                break;
            }
        }