Exemple #1
0
        public string AddDevice(string type, string id, string name, string path, RepositoryRepresentation repoDevice)
        {
            if (checkForSameDevID(id))
            {
                return(Properties.Resources.SameDevIDEx);
            }

            if (name == null)
            {
                name = "";
            }

            if (repoDevice.hasParent())
            {
                return("Device cant be added to a childDevice"); //TODO: Create good Response and localize it
            }
            Device newDevice = deviceProducer.produceDevice(type, id, name, path, getCompleteDeviceList());

            if (newDevice == null)
            {
                return(Properties.Resources.UnknownError);
            }

            checkAndWriteColorForNewDevice(newDevice);
            newDevice.addParent(repoDevice);
            repoDevice.getDevices().Add(newDevice);
            return(newDevice.Id);
        }