public bool SetDeviceState(int id, bool state)
        {
            if (id < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            bool methodRetVal = _deviceRepo.SetState(id, state);

            if (methodRetVal)
            {
                DevicesChange?.Invoke();
            }
            return(methodRetVal);
        }
        public bool RemoveDevice(DeviceDTO deviceToRemove)
        {
            bool retVal;

            try
            {
                retVal = _deviceRepo.Remove(deviceToRemove.Id);
            }
            catch (InvalidDeviceDataException)
            {
                return(false);
            }
            DevicesChange?.Invoke();
            return(retVal);
        }
        public bool AddDevice(DeviceDTO newDevice)
        {
            DeviceField invalidFields = DeviceField.None;

            if (newDevice.Id < 0)
            {
                invalidFields |= DeviceField.Id;
            }

            if (newDevice.Name == "")
            {
                invalidFields |= DeviceField.Name;
            }

            if (invalidFields != DeviceField.None)
            {
                throw new InvalidDeviceDataException(invalidFields);
            }

            _deviceRepo.Add(Mapper.Map(newDevice));
            DevicesChange?.Invoke();
            return(true);
        }
 public void DevicesChangedInvoke()
 {
     DevicesChange?.Invoke();
 }