Exemple #1
0
        //[DisableCors]
        public ActionResult <string> Counter([FromBody] CounterModel counter)
        {
            string result = "error";

            try
            {
                DevicesRepository devices = new DevicesRepository(_options);

                if (devices.GetDeviceBySerial(counter.Serial).Count == 0)
                {
                    result = devices.InsertCounter(counter.Serial, counter.Brand, counter.Model, counter.Type);
                }
                else
                {
                    result = "The serial number entered was already registered. Please check the serial number.";
                }
            }
            catch (Exception ex)
            {
                return("Error: " + ex.Message);
            }

            return(result);
        }