/// <summary> /// ServerSettings /// </summary> public ServerSettings() { InitializeComponent(); NavigationPage.SetBackButtonTitle(this, string.Empty); BindingContext = _viewModel = new ServerSettingsViewModel(this); NavigationPage.SetHasBackButton(this, _viewModel.IsServerAddressExist); //serverAddrsEntry.Completed += serverAddrsEntryText_Input_Completed; //serverPortEntry.Completed += serverPortEntryText_Input_Completed; languageList.ItemSelected += (sender, e) => { if (languageList.SelectedItem == null) { return; } if (!IsListViewSelected || !HaccpAppSettings.SharedInstance.IsWindows) { IsListViewSelected = true; var language = (Language)languageList.SelectedItem; if (_viewModel != null) { _viewModel.SelectLanguageAndDownloadStrings(language); } } else { IsListViewSelected = false; } }; }
private void ServerSettingsView_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { _viewModel = e.NewValue as ServerSettingsViewModel; if (_viewModel != null) { // Password is just a OneWayBinding. Therefore just set the initial value _passwordBox.Password = SecureStringUtility.ToUnsecureString(_viewModel.Password); } }
public ServerSettingsViewModel Generate() { var serverSettingsViewModel = new ServerSettingsViewModel(); serverSettingsViewModel.Applications.GetApplication = _routesForApi.Applications.GetApplication(); serverSettingsViewModel.Applications.Search = _routesForApi.Applications.Search(); serverSettingsViewModel.Applications.GetLogs = _routesForApi.Applications.GetLogs(); return(serverSettingsViewModel); }
private ServerSettingsViewModel makeVm(ServerSettings settings) { ServerSettingsViewModel ssvm = new ServerSettingsViewModel() { DefaultMarket = settings.DefaultMarket, ResponseModeDescription = settings.ResponseMode.Description, ServerSettingsId = settings.ServerSettingsId, ResponseModeId = settings.ResponseMode.Name.ToString(), RateLimits = makeRateVm(settings.RateLimits) }; return(ssvm); }
public async Task <IActionResult> SaveSettings(ServerSettingsViewModel vm) { if (!ModelState.IsValid) { return(RedirectToLocal("/settings")); } if (!Country.SpotifyMarkets.Select(x => x.FormalName).Contains(vm.DefaultMarket)) { ModelState.AddModelError(string.Empty, "Supplied default country not a valid country"); } // TODO View is supplying the Name to us, but it should be supplying the Id if (!SpecialResponseMode.SpecialResponseModes.Select(x => x.Name).Contains(vm.ResponseModeId)) { ModelState.AddModelError(string.Empty, "Supplied Special Response Mode not a valid Special Response Mode"); } if (vm.RateLimits.CallsPerWindow > RateLimits.MaxRateLimit) { ModelState.AddModelError(string.Empty, $"Supplied Calls per Window is greater than the maximum supported ({RateLimits.MaxRateLimit})"); } if (vm.RateLimits.CallsPerWindow < RateLimits.MinRateLimit) { ModelState.AddModelError(string.Empty, $"Supplied Calls per Window is less than the minimum supported ({RateLimits.MinRateLimit})"); } if (vm.RateLimits.RateWindowInMinutes > RateLimits.MaxTimeWindowMinutes) { ModelState.AddModelError(string.Empty, $"Supplied Time Window is greater than the maximum supported ({RateLimits.MaxTimeWindowMinutes})"); } if (vm.RateLimits.RateWindowInMinutes < RateLimits.MinTimeWindowMinutes) { ModelState.AddModelError(string.Empty, $"Supplied Time Window is less than the minimum supported ({RateLimits.MinTimeWindowMinutes})"); } if (ModelState.ErrorCount > 0) { return(View()); } else { // Save the new settings ServerSettings.Settings.DefaultMarket = vm.DefaultMarket; ServerSettings.Settings.ResponseMode = SpecialResponseMode.SpecialResponseModes.Where(x => x.Name == vm.ResponseModeId).First(); ServerSettings.Settings.RateLimits.CallsPerWindow = vm.RateLimits.CallsPerWindow; ServerSettings.Settings.RateLimits.RateWindow = TimeSpan.FromMinutes(vm.RateLimits.RateWindowInMinutes); _mc.ServerSettings.Update(ServerSettings.Settings); await _mc.SaveChangesAsync(); } return(Ok()); }
public async Task <IActionResult> Index() { ServerSettingsViewModel ssvm = makeVm(ServerSettings.Settings); return(View(ssvm)); }
public ServerSettingsView() { InitializeComponent(); DataContext = new ServerSettingsViewModel(); }