public ActionResult Wake(WOLIndexViewModel model) { var hostSettings = new Dictionary <int, WOLHostSettingModel>(); for (int i = 0; i < _hostSettings.WOLHosts.Count; i++) { hostSettings.Add(i, _hostSettings.WOLHosts[i]); } var wakeHost = hostSettings[model.selectedHostId]; _wOLService.Wake(wakeHost.MacAddress, wakeHost.BroadcastIP); _logger.Log(LogLevel.Information, $"Sent packets to wake {wakeHost.FriendlyName}"); _flashMessage.Confirmation($"🚀 Wakeup call sent for {wakeHost.FriendlyName}"); return(RedirectToAction(nameof(Index))); }
// GET: WOLController public ActionResult Index() { var hostSettingsDTOs = new List <WOLHostSettingsDTO>(); for (int i = 0; i < _hostSettings.WOLHosts.Count; i++) { WOLHostSettingModel settings = _hostSettings.WOLHosts[i]; var dto = new WOLHostSettingsDTO(); _mapper.Map(settings, dto); dto.id = i; hostSettingsDTOs.Add(dto); } var viewModel = new WOLIndexViewModel { wolHosts = hostSettingsDTOs }; return(View(viewModel)); }