public IActionResult Edit(GeneralSetting model) { AlertBack alert = new AlertBack(); try { if (ModelState.IsValid) { _generalSettingService.Update(model); alert.Status = "success"; alert.Message = "Register Successfully"; } else { alert.Status = "warning"; foreach (var key in this.ViewData.ModelState.Keys) { foreach (var err in this.ViewData.ModelState[key].Errors) { alert.Message += err.ErrorMessage + "<br/>"; } } } } catch (Exception ex) { alert.Status = "error"; alert.Message = ex.Message; } return(Json(alert)); }
public override void Reload() { base.Reload(); if (_viewModel.Settings == null) { _viewModel.Settings = _service.GetForUser(GlobalVariables.UserId); _viewModel.Settings.PropertyChanged += (sender, e) => { // set new language if (e.PropertyName == nameof(GeneralSettingModel.Language)) { MultiLangResourceManager.Instance.SetLanguage(_viewModel.Settings.Language); AppSettings.Instance.LastLanguage = _viewModel.Settings.Language; AppSettings.Instance.Save(); } // set new accent color if (e.PropertyName == nameof(GeneralSettingModel.AccentColor)) { MCThemeManager.Instance.SetAccentColor(_viewModel.Settings.AccentColor); AppSettings.Instance.LastAccentColor = _viewModel.Settings.AccentColor; AppSettings.Instance.Save(); } // set new theme color if (e.PropertyName == nameof(GeneralSettingModel.ThemeColor)) { MCThemeManager.Instance.SetThemeColor(_viewModel.Settings.ThemeColor); AppSettings.Instance.LastThemeColor = _viewModel.Settings.ThemeColor; AppSettings.Instance.Save(); } // save changes _service.Update(_viewModel.Settings); }; } }
public AlertBack PutGeneralSetting([FromForm] GeneralSetting model, int id = 0) { AlertBack alert = new AlertBack(); if (ModelState.IsValid) { generalSettingService.Update(model); alert.status = "success"; alert.message = "Register Successfully"; return(alert); } else { alert.status = "warning"; foreach (var key in this.ModelState.Keys) { foreach (var err in this.ModelState[key].Errors) { alert.message += err.ErrorMessage + "<br/>"; } } return(alert); } }