public ActionResult SaveSettings(string model, bool isSharedAccount) { var accountId = HttpContext.Session.Get <long>(SessionHelper.SessionKeyAccountId); if (accountId == default) { return(RedirectToAction("Login", "Account", new { id = LoginHelper.BudgetApp })); } var savingAccountId = isSharedAccount ? AccountHelper.GetSharedAccountId(accountId) : accountId; var settings = model.Split("|"); foreach (var setting in settings) { string contextKey; string contextValue; object settingValue; if (IsValidSettingString(setting, "CATEGORY")) { contextKey = SettingsHelper.CategorySettingKey; contextValue = GetCategorySettingContextValue(setting); settingValue = ParseCategorySetting(setting); } else if (IsValidSettingString(setting, "EXPENSESUMMARYTIMEPERIOD")) { contextKey = SettingsHelper.ExpenseSummarySettingKey; contextValue = SettingsHelper.TimePeriodSettingValue; settingValue = ParseExpenseSummarySetting(setting); } else { throw new NotImplementedException(); } AccountRepository.AddOrUpdateAccountSetting(savingAccountId, contextKey, contextValue, settingValue); } return(Json(new { status = true, message = "Settings Saved" })); }