public void registerBayRackLevel(BayRackLevelRequest bayRackLevel)
 {
     if (!(new AiGrow.Business.BL_BayRackLevel().doesBayRackLevelExist(bayRackLevel.bay_rack_level_unique_id)))
     {
         new BL_BayRackLevel().insert(new ML_BayRackLevel()
         {
             rack_id         = bayRackLevel.rack_id,
             level_unique_id = bayRackLevel.bay_rack_level_unique_id
         });
     }
     else
     {
         BaseResponse response = new BaseResponse();
         response.success      = false;
         response.errorMessage = UniversalProperties.DUPLICATE_BAY_RACK_LEVEL;
         response.requestID    = bayRackLevel.requestID;
         response.deviceID     = bayRackLevel.bay_rack_level_unique_id;
         response.errorCode    = UniversalProperties.EC_RegistrationError;
         string responseJSON = new JavaScriptSerializer().Serialize(response);
         new MQTTHandler().Publish(UniversalProperties.MQTT_topic, responseJSON);
     }
 }
        public bool registerBayRackLevel(BayRackLevelRequest level)
        {
            try
            {
                new DatabaseUpdate().registerBayRackLevel(level);

                foreach (BayRackLevelDeviceRequest device in level.listOfLevelDevices)
                {
                    device.requestID = level.requestID;
                    new DatabaseUpdate().registerBayRackLevelDevice(device);
                }
                foreach (BayRackLevelLineRequest line in level.listOfLevelLines)
                {
                    line.requestID = level.requestID;
                    registerBayRackLevelLine(line);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }