public IActionResult Edit(FirstTimeConfigViewModel ftcViewModel) { if (ModelState.IsValid) { hubConfig.Email = ftcViewModel.HarmonyEmail; if (!String.IsNullOrEmpty(ftcViewModel.HarmonyPassword)) { hubConfig.Password = ftcViewModel.HarmonyPassword; } hubConfig.HubAddress = ftcViewModel.HarmonyHubAddress; hubConfig.HubPort = ftcViewModel.HarmonyHubPort; // Refresh the connection ftcViewModel.IsConnected = myHub.StartNewConnection(hubConfig.Email, hubConfig.Password, hubConfig.HubAddress, hubConfig.HubPort); if (ftcViewModel.IsConnected == false) { ModelState.AddModelError("HarmonyPassword", "Could not authenticate with harmony cloud service"); return(View(ftcModel())); } hubConfig.VolumeDevice = ftcViewModel.VolumeDevice; hubConfig.ChannelDevice = ftcViewModel.ChannelDevice; // Save the new data j64HarmonyGatewayRepository.Save(hubConfig); } // Redirect to the install smart apps page once we are done with this first time configuration if (ftcViewModel.IsConnected && !String.IsNullOrEmpty(ftcViewModel.VolumeDevice) && !String.IsNullOrEmpty(ftcViewModel.ChannelDevice)) { return(RedirectToAction("Index", "Oauth")); } return(View(ftcModel())); }
public IActionResult Edit(FirstTimeConfigViewModel ftcViewModel) { if (ModelState.IsValid) { hubConfig.Email = ftcViewModel.HarmonyEmail; if (!String.IsNullOrEmpty(ftcViewModel.HarmonyPassword)) hubConfig.Password = ftcViewModel.HarmonyPassword; hubConfig.HubAddress = ftcViewModel.HarmonyHubAddress; hubConfig.HubPort = ftcViewModel.HarmonyHubPort; // Refresh the connection ftcViewModel.IsConnected = myHub.StartNewConnection(hubConfig.Email, hubConfig.Password, hubConfig.HubAddress, hubConfig.HubPort); if (ftcViewModel.IsConnected == false) { ModelState.AddModelError("HarmonyPassword", "Could not authenticate with harmony cloud service"); return View(ftcModel()); } hubConfig.VolumeDevice = ftcViewModel.VolumeDevice; hubConfig.ChannelDevice = ftcViewModel.ChannelDevice; // Save the new data j64HarmonyGatewayRepository.Save(hubConfig); } // Redirect to the install smart apps page once we are done with this first time configuration if (ftcViewModel.IsConnected && !String.IsNullOrEmpty(ftcViewModel.VolumeDevice) && !String.IsNullOrEmpty(ftcViewModel.ChannelDevice)) return RedirectToAction("Index", "Oauth"); return View(ftcModel()); }
private FirstTimeConfigViewModel ftcModel() { var ftcm = new FirstTimeConfigViewModel() { HarmonyHubAddress = hubConfig.HubAddress, HarmonyHubPort = hubConfig.HubPort, HarmonyEmail = hubConfig.Email, HarmonyPassword = hubConfig.Password, VolumeDevice = hubConfig.VolumeDevice, ChannelDevice = hubConfig.ChannelDevice }; if (myHub.hubConfig != null) ftcm.IsConnected = true; ftcm.VolumeDeviceList = GetDeviceList(ftcm.VolumeDevice); ftcm.ChannelDeviceList = GetDeviceList(ftcm.ChannelDevice); return ftcm; }
private FirstTimeConfigViewModel ftcModel() { var ftcm = new FirstTimeConfigViewModel() { HarmonyHubAddress = hubConfig.HubAddress, HarmonyHubPort = hubConfig.HubPort, HarmonyEmail = hubConfig.Email, HarmonyPassword = hubConfig.Password, VolumeDevice = hubConfig.VolumeDevice, ChannelDevice = hubConfig.ChannelDevice }; if (myHub.hubConfig != null) { ftcm.IsConnected = true; } ftcm.VolumeDeviceList = GetDeviceList(ftcm.VolumeDevice); ftcm.ChannelDeviceList = GetDeviceList(ftcm.ChannelDevice); return(ftcm); }