Пример #1
0
        public async Task <string> SetDeviceStatus(int status)
        {
            try
            {
                weatherContext _db          = new weatherContext();
                var            deviceStatus = _db.DeviceStatus.FirstOrDefault();
                if (deviceStatus != null)
                {
                    if (status == 1)
                    {
                        deviceStatus.Fan = true;
                        await _db.SaveChangesAsync();

                        return("включить");
                    }
                    else
                    if (status == 0)
                    {
                        deviceStatus.Fan = false;
                        await _db.SaveChangesAsync();

                        return("выключить");
                    }
                }
                return("Получен невалидный аргумент");
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Пример #2
0
        public async Task <IActionResult> Adder([FromBody] Turkey turkey)
        {
            _weather.Add(turkey);
            await _weather.SaveChangesAsync();

            return(Ok());
        }