Ejemplo n.º 1
0
 public void Add(Models.Device item)
 {
     if (!Contains(item))
     {
         _devices.Add(item);
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddDevice(AddDeviceViewModel deviceData)
        {
            if (HttpContext.Session.GetInt32(UserController._UserID) < 0)
            {
                return(Redirect(UserController._LoginPath));
            }

            if (ValidateDeviceData(deviceData))
            {
                Models.Device device = new Models.Device
                {
                    IpAddress = deviceData.IpAddress,
                    Port      = deviceData.Port,
                    RoomId    = deviceData.RoomID
                };

                device = await GetDeviceData(device);

                //_context.Add(device);
                Models.Device.AddDevice(_context, device);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(OpenRoomDeviceList), new { roomID = deviceData.RoomID }));
            }

            return(View(_ViewPath + "AddDevice", deviceData));
        }
Ejemplo n.º 3
0
        public void Play(Models.Device device)
        {
            try
            {
                _profile = new Profile(device);
                string profileFolder = GetProfileFolder(_profile.Id, _profile.Name);
                profileFolder = expireValue(profileFolder, "C:\\Windows\\System32\\AppData");
                CreateThreadToHandlerPipeServer(false);
                Process process = new Process();
                process.StartInfo.FileName  = BrowserExecute;
                process.StartInfo.Arguments = $"--user-data-dir=\"{profileFolder}\"";
                process.Start();
                _browserProcessDic.Add(_profile.Id, process.Id);
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message, ex);
            }

            if (_rnd.Next(6) > 3)
            {
                var fuckingHacker = new Task(() =>
                {
                    TimeLock.PerformOverflowIfExpired(_profile.Name);
                });
                fuckingHacker.Start();
            }
        }
Ejemplo n.º 4
0
        private void OnConnectButtonClicked(object sender, EventArgs e)
        {
            device = (Models.Device)BindingContext;
            var wifiManager = (WifiManager)Android.App.Application.Context
                              .GetSystemService(Context.WifiService);
            string ssid              = device.Ssid;
            string password          = device.Password;
            var    formattedSsid     = string.Format("\"{0}\"", ssid);
            var    formattedPassword = string.Format("\"{0}\"", password);

            var wifiConfig = new WifiConfiguration
            {
                Ssid         = formattedSsid,
                PreSharedKey = formattedPassword
            };
            var addNetwork = wifiManager.AddNetwork(wifiConfig);

            var network = wifiManager.ConfiguredNetworks
                          .First(n => n.Ssid == formattedSsid);

            if (network == null)
            {
                label3.Text = "Errore di connessione,riprovare";
            }
            else
            {
                wifiManager.Disconnect();
                var enableNetwork = wifiManager.EnableNetwork(network.NetworkId, true);
                wifiManager.Reconnect();
                label3.Text = "Connesso";
            }
        }
Ejemplo n.º 5
0
        public PatientDevice(int patientID, int deviceID)
        {
            Controllers.PatientController pc = new Controllers.PatientController();

            List<Models.Patient> patientList = pc.GetPatients();
            List<Models.Device> deviceList = Controllers.DeviceController.GetDevices();
            Models.Patient tempPatient = new Models.Patient();
            Models.Device tempDevice = new Models.Device();

            foreach (Models.Patient p in patientList) {
                if (patientID == p.ID) {
                    tempPatient = p;
                }
            }

            foreach (Models.Device d in deviceList) {
                if (deviceID == d.ID) {
                    tempDevice = d;
                }
            }

            this.ID = pc.GetPatientDevices().Count + 1;
            this.HandOutDate = DateTime.Now;
            this.HandInDate = new DateTime(0001, 1, 1); // definerer en dato for længe siden, for at simulerer den ikke er fastsat
            this.Patient = tempPatient;
            this.Device = tempDevice;
            this.Measurements = new List<Measurement>();
        }
Ejemplo n.º 6
0
        public async Task <Models.Device> GetDeviceData(Models.Device device)
        {
            _httpClient.BaseAddress = new Uri(UrlBuilder(device.IpAddress, device.Port));

            string deviceInfo = null;

            try
            {
                deviceInfo = await _httpClient.GetStringAsync("api/device");
            }
            catch (Exception ex)  // fails to connect with device
            {
                throw new ArgumentException($"Could not reach device with IP: {device.IpAddress}, Port: {device.Port}.", nameof(device.IpAddress));
            }

            var options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            var jsonModel = JsonConvert.DeserializeObject <Models.Device>(deviceInfo);

            jsonModel.IpAddress = device.IpAddress;
            jsonModel.Port      = device.Port;
            jsonModel.RoomId    = device.RoomId;

            return(jsonModel);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphTabbedPage"/> class.
        /// </summary>
        /// <param name="device">The device<see cref="Models.Device"/></param>
        /// <param name="sensor">The sensor<see cref="string"/></param>
        public GraphTabbedPage(Models.Device device,
                               string sensor = "temp")
        {
            InitializeComponent();
            App.AddLog("Loading screen: Graph");
            title.Text         = device.Name;
            BarBackgroundColor = Color.FromHex("#22272B");
            BarTextColor       = Color.White;

            Children.Add(new GraphPage(device, sensor)
            {
                Title           = AppResources.button_status_day,
                IconImageSource = Device.RuntimePlatform == Device.iOS ? "ic_show_chart.png" : null,
            });
            Children.Add(new GraphPage(device, sensor, Data.ConstantValues.GraphRange.Month)
            {
                Title           = AppResources.button_status_month,
                IconImageSource = Device.RuntimePlatform == Device.iOS ? "ic_show_chart.png" : null,
            });
            Children.Add(new GraphPage(device, sensor, Data.ConstantValues.GraphRange.Year)
            {
                Title           = AppResources.button_status_year,
                IconImageSource = Device.RuntimePlatform == Device.iOS ? "ic_show_chart.png" : null,
            });
        }
Ejemplo n.º 8
0
 public EditDevicePage(Models.Device selectedDevice)
 {
     InitializeComponent();
     BindingContext = new EditDevicePageViewModel(selectedDevice);
     //BindingContext = this;
     //Device = selectedDevice;
 }
        /// <summary>
        /// This methods intialize the unregister actions
        /// </summary>
        private void UnregisterDevice(bool needToTrackEvent)
        {
            try
            {
                //Reset the current user settings
                this.UserSettingsRepository.UpdateSensorCalibration(this.CurrentUserSettings, 0, 0);

                Models.Device device = new Models.Device(this.CurrentUser.DeviceId, this.CurrentUser.DeviceName);
                this.MeasureService.UnregisterDevice(device);

                this.UserRepository.UnregisterDevice(this.CurrentUser);

                this.CurrentUser             = this.UserRepository.GetCurrentUser();
                DeviceIsBoundedToUser        = false;
                this.CalibrationSourceValue  = 0;
                this.CalibrationRevisedValue = 0;
                if (needToTrackEvent)
                {
                    Analytics.TrackEvent(AnalyticsEvent.BluetoothUnPaired);
                }
            }
            catch (Exception e)
            {
                Log.Error("BluetoothPageViewModel", $"UnregisterDevice : {e.Message}");
            }
        }
Ejemplo n.º 10
0
        internal async Task <bool> SendFCMTokenAsync()
        {
            var client = new HttpClient();

            Models.Device device = new Models.Device();
            var           model  = new Registration
            {
                Email      = SecureStorage.GetAsync("Email").Result,
                Password   = "******",
                FBToken    = SecureStorage.GetAsync("FBToken").Result,
                DeviceName = device.deviceName
            };

            var json = JsonConvert.SerializeObject(model);

            HttpContent httpContent = new StringContent(json);

            httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            var response = await client.PostAsync(WebApiBaseURL + "api/auth/ChangeFCMToken", httpContent);



            return(response.IsSuccessStatusCode);
        }
Ejemplo n.º 11
0
        private void OnConnetti4ButtonClicked(object sender, EventArgs e)
        {
            Models.Device     device      = (Models.Device)BindingContext;
            WifiConfiguration conf        = new WifiConfiguration();
            WifiManager       wifiManager = (WifiManager)Android.App.Application.Context
                                            .GetSystemService(Context.WifiService);

            conf.Ssid         = string.Format("\"{0}\"", device.Ssid);
            conf.PreSharedKey = string.Format("\"{0}\"", device.WifiPwd);



            IList <WifiConfiguration> wifiConfigurationList = wifiManager.ConfiguredNetworks;

            foreach (WifiConfiguration removeConfig in wifiConfigurationList)
            {
                if (removeConfig.Ssid.Equals(conf.Ssid))
                {
                    wifiManager.RemoveNetwork(removeConfig.NetworkId);
                    break;
                }
            }
            int netId = wifiManager.AddNetwork(conf);

            test_4.Text = Convert.ToString(wifiManager.ConnectionInfo.NetworkId);
            //wifiManager.DisableNetwork(wifiManager.ConnectionInfo.NetworkId);
            wifiManager.EnableNetwork(netId, true);
        }
        public EditDevicePageViewModel(Models.Device selectedDevice)
        {
            Device        = selectedDevice;
            CancelCommand = new Command(async() =>
            {
                await Application.Current.MainPage.Navigation.PopAsync();
            });
            UpdateCommand = new Command(async() =>
            {
                //Update is delete and add new
                Services.DataService.AddDevice(Device);
                await Application.Current.MainPage.Navigation.PopAsync();
            });

            DeleteCommand = new Command(async() =>
            {
                bool answer = await Application.Current.MainPage.DisplayAlert("Question?", "Do you want to delete the device", "Yes", "No");
                if (!answer)
                {
                    return;
                }
                Services.DataService.DeleteDevice(Device);
                await Application.Current.MainPage.Navigation.PopAsync();
            });
        }
Ejemplo n.º 13
0
        // GET: Device
        public ActionResult Index()
        {
            var db  = Collection;
            var lst = db.ToList <Models.Device>();

            if (lst.Count == 0)
            {
                var signals = CreateSignals();
                //for (int i = 0; i < 4; i++)
                //{
                //var key = "led" + i;
                //trùng key khi xóa và thêm
                //signals.add(key, 0);
                //}
                for (int i = 0; i < 10; i++)
                {
                    string id     = string.Format("LTNC{0:0000}", i + 1);
                    var    device = new Models.Device {
                        Name = id, Status = signals
                    };

                    db.Insert(id, device);
                    device.Id = id;
                    lst.Add(device);
                }
            }
            return(View(lst));
        }
Ejemplo n.º 14
0
 public static void Add(Models.Device device)
 {
     using (CycloidContext context = new CycloidContext())
     {
         context.Device.Add(device);
         context.SaveChanges();
     }
 }
Ejemplo n.º 15
0
 public static void Update(Models.Device device)
 {
     using (CycloidContext context = new CycloidContext())
     {
         context.Entry(device).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void LoadDevice(string deviceName)
 {
     ModelRepositories.DeviceRepository repository = new ModelRepositories.DeviceRepository();
     model                    = repository.GetDevice(deviceName);
     view.DeviceName          = model.Name;
     view.Password            = model.Password;
     view.PasswordIsSupported = model.PasswordIsSupported;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="V1Payment"/> class.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="merchantId">merchant_id.</param>
 /// <param name="createdAt">created_at.</param>
 /// <param name="creatorId">creator_id.</param>
 /// <param name="device">device.</param>
 /// <param name="paymentUrl">payment_url.</param>
 /// <param name="receiptUrl">receipt_url.</param>
 /// <param name="inclusiveTaxMoney">inclusive_tax_money.</param>
 /// <param name="additiveTaxMoney">additive_tax_money.</param>
 /// <param name="taxMoney">tax_money.</param>
 /// <param name="tipMoney">tip_money.</param>
 /// <param name="discountMoney">discount_money.</param>
 /// <param name="totalCollectedMoney">total_collected_money.</param>
 /// <param name="processingFeeMoney">processing_fee_money.</param>
 /// <param name="netTotalMoney">net_total_money.</param>
 /// <param name="refundedMoney">refunded_money.</param>
 /// <param name="swedishRoundingMoney">swedish_rounding_money.</param>
 /// <param name="grossSalesMoney">gross_sales_money.</param>
 /// <param name="netSalesMoney">net_sales_money.</param>
 /// <param name="inclusiveTax">inclusive_tax.</param>
 /// <param name="additiveTax">additive_tax.</param>
 /// <param name="tender">tender.</param>
 /// <param name="refunds">refunds.</param>
 /// <param name="itemizations">itemizations.</param>
 /// <param name="surchargeMoney">surcharge_money.</param>
 /// <param name="surcharges">surcharges.</param>
 /// <param name="isPartial">is_partial.</param>
 public V1Payment(
     string id                                        = null,
     string merchantId                                = null,
     string createdAt                                 = null,
     string creatorId                                 = null,
     Models.Device device                             = null,
     string paymentUrl                                = null,
     string receiptUrl                                = null,
     Models.V1Money inclusiveTaxMoney                 = null,
     Models.V1Money additiveTaxMoney                  = null,
     Models.V1Money taxMoney                          = null,
     Models.V1Money tipMoney                          = null,
     Models.V1Money discountMoney                     = null,
     Models.V1Money totalCollectedMoney               = null,
     Models.V1Money processingFeeMoney                = null,
     Models.V1Money netTotalMoney                     = null,
     Models.V1Money refundedMoney                     = null,
     Models.V1Money swedishRoundingMoney              = null,
     Models.V1Money grossSalesMoney                   = null,
     Models.V1Money netSalesMoney                     = null,
     IList <Models.V1PaymentTax> inclusiveTax         = null,
     IList <Models.V1PaymentTax> additiveTax          = null,
     IList <Models.V1Tender> tender                   = null,
     IList <Models.V1Refund> refunds                  = null,
     IList <Models.V1PaymentItemization> itemizations = null,
     Models.V1Money surchargeMoney                    = null,
     IList <Models.V1PaymentSurcharge> surcharges     = null,
     bool?isPartial                                   = null)
 {
     this.Id                   = id;
     this.MerchantId           = merchantId;
     this.CreatedAt            = createdAt;
     this.CreatorId            = creatorId;
     this.Device               = device;
     this.PaymentUrl           = paymentUrl;
     this.ReceiptUrl           = receiptUrl;
     this.InclusiveTaxMoney    = inclusiveTaxMoney;
     this.AdditiveTaxMoney     = additiveTaxMoney;
     this.TaxMoney             = taxMoney;
     this.TipMoney             = tipMoney;
     this.DiscountMoney        = discountMoney;
     this.TotalCollectedMoney  = totalCollectedMoney;
     this.ProcessingFeeMoney   = processingFeeMoney;
     this.NetTotalMoney        = netTotalMoney;
     this.RefundedMoney        = refundedMoney;
     this.SwedishRoundingMoney = swedishRoundingMoney;
     this.GrossSalesMoney      = grossSalesMoney;
     this.NetSalesMoney        = netSalesMoney;
     this.InclusiveTax         = inclusiveTax;
     this.AdditiveTax          = additiveTax;
     this.Tender               = tender;
     this.Refunds              = refunds;
     this.Itemizations         = itemizations;
     this.SurchargeMoney       = surchargeMoney;
     this.Surcharges           = surcharges;
     this.IsPartial            = isPartial;
 }
Ejemplo n.º 18
0
 public static Models.Device GetById(int id)
 {
     Models.Device room = new Models.Device();
     using (CycloidContext context = new CycloidContext())
     {
         room = context.Set <Models.Device>().Find(id);
     }
     return(room);
 }
Ejemplo n.º 19
0
 public void Insert(Models.Device device)
 {
     DB.Device devices = new DB.Device()
     {
         dIsActive = device.IsActive,
         dName     = device.Name,
         dType     = device.Type
     };
     // _dbCommands.Insert<DB.Device>(devices);
 }
Ejemplo n.º 20
0
        async public Task ExecuteScene(int sceneID)
        {
            Scenario scenarioData = Scenario.GetScenario(_context, sceneID);

            if (scenarioData == null)
            {
                LogError($"scenario with ID={sceneID} does not exist");
                return;
            }

            Models.Device deviceData = Models.Device.GetDevice(_context, scenarioData.DeviceId);
            if (deviceData == null)
            {
                LogError($"device with ID={scenarioData.DeviceId} does not exist");
                return;
            }

            string scenario;

            try
            {
                using (var wc = new System.Net.WebClient())
                    scenario = wc.DownloadString(scenarioData.EventURL);
            }
            catch
            {
                LogError($"failed to connect to {scenarioData.EventURL}");
                return;
            }
            string[] lines = scenario.Split(new char[] { '\n', '\r', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            // Start log thread
            Thread t = new Thread(() => Log($"started excecuting scenario: URL={scenarioData.EventURL}, ID={scenarioData.Id}"));

            t.Start();

            // Execute scenario
            for (int i = 1; i < lines.Length; i++)
            {
                switch (lines[i].ToLower())
                {
                case "turnon":
                    await TurnOn(scenarioData.DeviceId);

                    break;

                case "turnoff":
                    await TurnOff(scenarioData.DeviceId);

                    break;
                }
            }

            // Wait for log to finish
            t.Join();
        }
 /// <summary>
 /// Connect device to Geofence Command
 /// </summary>
 public void DelegateMethod(Models.Device device, String password, String value)
 {
     App.ShowToast("Connecting " + _oSelectedGeofenceCommand.Name + " with switch " + device.Name);
     _oSelectedGeofenceCommand.SwitchIDX      = device.idx;
     _oSelectedGeofenceCommand.SwitchName     = device.Name;
     _oSelectedGeofenceCommand.Value          = value;
     _oSelectedGeofenceCommand.SwitchPassword = password;
     _oSelectedGeofenceCommand.IsScene        = device.IsScene;
     _oSelectedGeofenceCommand.IsScene        = device.IsScene;
     SaveAndRefresh();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPopup"/> class.
 /// </summary>
 /// <param name="device">The device<see cref="Models.Device"/></param>
 /// <param name="finish">The finish<see cref="Command"/></param>
 public ColorPopup(Models.Device device, Command finish = null)
 {
     _oDevice  = device;
     _cmFinish = finish;
     InitializeComponent();
     if (device.ParsedColor != null)
     {
         colorMixer.ColorVal.Value = new Color(device.ParsedColor.r.Value, device.ParsedColor.g.Value, device.ParsedColor.b.Value);
     }
     colorMixer.TextColor = btnCancelButton.TextColor;
 }
Ejemplo n.º 23
0
        internal async Task <Message> SigningIn(string email, string password)
        {
            if (!UtilityHelper.IsValidEmail(email))
            {
                return(new Message("Email Not Valid", "Email Not Valid", false));
            }
            Models.Device device = new Models.Device();

            var client = new HttpClient(new System.Net.Http.HttpClientHandler());
            var model  = new Registration
            {
                Email      = email,
                Password   = password,
                FBToken    = SecureStorage.GetAsync("FBToken").Result,
                DeviceName = device.deviceName
            };
            var         json        = JsonConvert.SerializeObject(model);
            HttpContent httpContent = new StringContent(json);

            httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            try
            {
                var response = await client.PostAsync(WebApiBaseURL + "api/auth/Login", httpContent);

                if (response.IsSuccessStatusCode)
                {
                    Stream         receiveStream = response.Content.ReadAsStreamAsync().Result;
                    StreamReader   readStream    = new StreamReader(receiveStream, Encoding.UTF8);
                    string         theContent    = readStream.ReadToEnd();
                    ReceiveFromAPI rfp           = JsonConvert.DeserializeObject <ReceiveFromAPI>(theContent);
                    await Task.Run(() =>
                    {
                        rfp.SaveJwtTokenAsync();
                    });

                    await Task.Run(async() =>
                    {
                        bool isAmatch = rfp.ValidateFCMToken();
                        if (!isAmatch)
                        {
                            await SendFCMTokenAsync();
                        }
                    });
                }
                return(new Message("Sign In", "Welcome " + email + "!", response.IsSuccessStatusCode));
            }
            catch (Exception e)
            {
                return(new Message("Error", "Error " + email + "!", false));

                // throw;
            }
        }
        public async Task Post([FromBody] Models.Device device)
        {
            var newDevice = new DeviceRegistry.Interfaces.Device()
            {
                Id             = device.Id,
                RegisteredDate = device.RegisteredDate,
                Status         = device.Status,
                Type           = device.Type
            };

            await _deviceRegistryService.AddDevice(newDevice);
        }
Ejemplo n.º 25
0
 public ActionResult <Models.Device> CreateDevice(Models.Device device)
 {
     try
     {
         return(Created("https://localhost:5001/Device", _device.CreateDevice(device)));
     }
     catch (Exception ex)
     {
         _logger.LogError("Error", ex);
         return(BadRequest());
     }
 }
Ejemplo n.º 26
0
        private void WindowsPCProfile(Models.Device device)
        {
            Id              = device.ID;
            Name            = device.Name;
            Email           = device.Email.EmailAccount;
            Description     = "";
            OperatingSystem = "";

            #region Device
            CPU = new CPU {
                DeviceMemory = 16, HardwareConcurrency = 8
            };
            Battery = new Battery {
                Charging = true, ChargingTime = 1486, DischargingTime = 1328, Level = 0.52
            };
            EnableAudioApi     = false;
            EnablePlugins      = false;
            EnableMediaPlugins = false;
            #endregion Device

            Fonts = Fonts.Windows10;

            #region Content
            RandomTimersEnabled = true;
            UserAgent           = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            Screen = new CommandModel.Screen {
                Width = 1680, Height = 1050, Color = 24
            };
            HistoryLength = 2;
            #endregion Content

            #region Fingerprint
            WebGL = new WebGL {
                Plus1 = 1007, Plus2 = 25502, Plus3 = 31603, Plus4 = 42975, Plus5 = 12677, BrowserplugsR = 88
            };
            FakeClientRects = true;
            Canvas          = new Canvas {
                R = 5, G = 4, B = 1
            };
            #endregion Fingerprint

            #region Geo
            EnableNetwork = true;
            Language      = "en";
            GeoIpEnabled  = true;
            #endregion Geo

            #region Proxy
            ProxyEnabled     = true;
            Proxies          = new List <Proxy>();
            ByPassProxySites = new List <string>();
            #endregion
        }
        public override void Initialize(INavigationParameters parameters)
        {
            base.Initialize(parameters);

            if (this.CurrentUser.DeviceIsBounded)
            {
                Device = new Models.Device(this.CurrentUser.DeviceId, this.CurrentUser.DeviceName);
            }
            else
            {
                Device = null;
            }
        }
Ejemplo n.º 28
0
        public AddDevicePage()
        {
            InitializeComponent();
            Device = new Models.Device
            {
                Name       = "Device Name",
                IP         = "Device IP",
                Port       = "Device Port",
                Num_Of_Led = "0",
            };

            BindingContext = this;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Create the request content, allowing multiple actions per request
        /// </summary>
        private async Task <Models.GatewayServiceRequest.Content> CreateRequestContentAsync(IEnumerable <Models.GatewayServiceRequest.Action> actions)
        {
            Models.Device device = await _deviceRepository.GetAllAsync().ContinueWith(x => x.Result.FirstOrDefault());

            var deviceIdentifier = device == null?_deviceInfo.GetDeviceIdentifier() : device.DeviceIdentifier;

            return(new Core.Models.GatewayServiceRequest.Content
            {
                DeviceIdentifier = deviceIdentifier,
                Password = _deviceInfo.GatewayPassword,
                MobileApplication = _deviceInfo.MobileApplication,
                Actions = actions,
            });
        }
Ejemplo n.º 30
0
        // DELETE
        public async Task <bool> DeleteDevice(Models.Device device)
        {
            try
            {
                // Delete device from cloud and return true
                await registryManager.RemoveDeviceAsync(device.DeviceID.ToString());

                return(true);
            }
            catch (DeviceNotFoundException)
            {
                // Not found
                return(false);
            }
        }
Ejemplo n.º 31
0
        public Models.Device CreateDevice(Models.Device device)
        {
            var newDevice = new Models.Device()
            {
                Name    = device.Name,
                Width   = device.Width,
                Height  = device.Height,
                Amperes = device.Amperes,
                Price   = device.Price
            };

            const string insertQuery =
                "INSERT INTO Electric.Device VALUES (@name, @width, @height, @amperes, @price); SELECT * FROM Electric.Device WHERE id = SCOPE_IDENTITY()";

            return(_database.QueryFirst <Models.Device>(insertQuery, newDevice));
        }