Exemplo n.º 1
0
        public ActionResult <string> Gateway([FromBody] GatewayModel gateway)
        {
            string result = "error";

            try
            {
                DevicesRepository devices = new DevicesRepository(_options);

                if (devices.GetDeviceBySerial(gateway.Serial).Count == 0)
                {
                    result = devices.InsertGateway(gateway.Serial, gateway.Brand, gateway.Ip, gateway.Port);
                }
                else
                {
                    result = "The serial number entered was already registered. Please check the serial number.";
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(result);
        }