public DeviceProxy(DEVICES device)
 {
     Id         = device.ID;
     IsEnabled  = device.IS_ENABLED;
     MacAddress = device.MAC_ADDRESS;
     Store      = device.STORE != null ? new StoreProxy(device.STORE) : null;
 }
Esempio n. 2
0
        public IHttpActionResult Save(DeviceProxy proxy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (proxy.Id == 0)
            {
                db.DEVICES.Add(new DEVICES
                {
                    IS_ENABLED  = proxy.IsEnabled,
                    MAC_ADDRESS = proxy.MacAddress,
                    STORE       = db.STORES.Find(proxy.Store.Id)
                });
            }
            else
            {
                DEVICES row = db.DEVICES.Find(proxy.Id);
                row.IS_ENABLED  = proxy.IsEnabled;
                row.MAC_ADDRESS = proxy.MacAddress;
                row.STORE       = db.STORES.Find(proxy.Store.Id);
            }

            try
            {
                db.SaveChanges();
                return(Ok());
            }
            catch (Exception e)
            {
                string error = e.GetBaseException().ToString();
                return(InternalServerError());
            }
        }
Esempio n. 3
0
        public IHttpActionResult Delete(int id)
        {
            DEVICES item = db.DEVICES.Find(id);

            if (item == null)
            {
                return(NotFound());
            }

            db.DEVICES.Remove(item);
            db.SaveChanges();

            return(Ok());
        }
    public static InputDevice CreateDeviceInput(DEVICES _device, int _ID = 0)
    {
        switch (_device)
        {
        case DEVICES.MOUSE_KEYBOARD:
        {
            return(new InputMK(_ID));
        }

        case DEVICES.PS4:
        {
            return(new InputPS4(_ID));
        }
        }

        return(null);
    }