public async Task<ActionResult> AddDevice()
        {
            var device = new Device();

            if (!this.TryUpdateModel(device))
            {
                return this.View("Add");
            }

            await this.deviceCommandManager.AddDeviceAsync(this.HttpContext.User.Identity.GetUserId(), device);
            return RedirectToAction("Index", new { Id = device.Id});
        }
        public async Task AddDeviceAsync(string personId, Device device)
        {
            var devices = await this.deviceQueryManager.GetDevicesAsync(personId);

            if (devices.Any(x => x.MacAddress == device.MacAddress || x.Name == device.Name))
            {
                throw new ArgumentException("You already have a device with the same name or MAC address.");
            }

            device.PersonId = personId;

            await this.deviceCommandStore.AddDeviceAsync(device);
        }
 public Task RemoveDeviceAsync(Device device)
 {
     this.databaseContext.Devices.Attach(device);
     this.databaseContext.Devices.Remove(device);
     return this.databaseContext.SaveChangesAsync();
 }
 public Task AddDeviceAsync(Device device)
 {
     this.databaseContext.Devices.Add(device);
     return this.databaseContext.SaveChangesAsync();
 }