public IActionResult GatewaySerial(SerialGatewayViewModel model) { //prevent start wizard if already passed if (!bool.Parse(configuration["FirstRun"])) { return(View("Error", ALREADY_PASSED_MESSAGE)); } //redirect to first step if user came this url directly if (SystemController.dataBaseConfig == null) { return(RedirectToAction("Index")); } dynamic json = ReadConfig(); json.Gateway.SerialGateway.SerialPortName = model.PortName; json.Gateway.SerialGateway.Boudrate = model.Boudrate; json.Gateway.SerialGateway.Enable = true; json.Gateway.EthernetGateway.Enable = false; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.ReadConfig(); SystemController.ConnectToGateway(); return(RedirectToAction("UserProfile")); }
public IActionResult SerialGateway(SerialGatewayViewModel model) { if (String.IsNullOrEmpty(model.PortName)) { return(RedirectToAction("SerialGateway")); } dynamic json = ReadConfig(); json.Gateway.SerialGateway.SerialPortName = model.PortName; json.Gateway.SerialGateway.Boudrate = model.Boudrate; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.gatewayConfig.SerialGateway.SerialPortName = model.PortName; SystemController.gatewayConfig.SerialGateway.Boudrate = model.Boudrate; return(RedirectToAction("Index")); }