示例#1
0
        //todo: think about changing it to one, chosen by some king of entry in globalSettings
        public Guid AddRaw(AcSettingAdd settingDto)
        {
            if (_currentAcDevice == null)
            {
                throw new CurrentACDeviceNotSetException();
            }

            var code = _codeRecordingService.RecordRawCode();

            var acSetting = new ACSetting
                            (
                code: code,
                settings: settingDto.Settings,
                isTurnOff: settingDto.IsTurnOff
                            );

            _currentAcDevice.AvailableSettings.Add(acSetting);
            return(acSetting.UniqueId);
        }
        public IActionResult AddRaw([FromBody] AcSettingAdd acSettingAdd)
        {
            try
            {
                var retVal = _acSettingsService.AddRaw(acSettingAdd);
                return(Ok(retVal));
            }

            catch (CurrentACDeviceNotSetException ex)
            {
                _logger.LogError(ex, "400: Bad request");
                return(BadRequest("Current ACDevice not set"));
            }

            catch (Exception ex)
            {
                _logger.LogError(ex, "500: Internal Server Error");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }