replaced IConfiguration injection with IConfigHelper

This commit is contained in:
DESKTOP-GENO133\IvanPlex 2024-01-14 09:54:13 -07:00
parent 8c6920afab
commit 8d74799099
16 changed files with 137 additions and 71 deletions

View File

@ -1,4 +1,5 @@
using CarCareTracker.Logic; using CarCareTracker.Helper;
using CarCareTracker.Logic;
using CarCareTracker.Models; using CarCareTracker.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -12,10 +13,12 @@ namespace CarCareTracker.Controllers
{ {
private ILoginLogic _loginLogic; private ILoginLogic _loginLogic;
private IUserLogic _userLogic; private IUserLogic _userLogic;
public AdminController(ILoginLogic loginLogic, IUserLogic userLogic) private IConfigHelper _configHelper;
public AdminController(ILoginLogic loginLogic, IUserLogic userLogic, IConfigHelper configHelper)
{ {
_loginLogic = loginLogic; _loginLogic = loginLogic;
_userLogic = userLogic; _userLogic = userLogic;
_configHelper = configHelper;
} }
public IActionResult Index() public IActionResult Index()
{ {
@ -38,7 +41,7 @@ namespace CarCareTracker.Controllers
} }
public IActionResult DeleteUser(int userId) public IActionResult DeleteUser(int userId)
{ {
var result =_userLogic.DeleteAllAccessToUser(userId) && _loginLogic.DeleteUser(userId); var result =_userLogic.DeleteAllAccessToUser(userId) && _configHelper.DeleteUserConfig(userId) && _loginLogic.DeleteUser(userId);
return Json(result); return Json(result);
} }
} }

View File

@ -52,7 +52,7 @@ namespace CarCareTracker.Controllers
[HttpPost] [HttpPost]
public IActionResult WriteToSettings(UserConfig userConfig) public IActionResult WriteToSettings(UserConfig userConfig)
{ {
var result = _config.SaveUserConfig(User.IsInRole(nameof(UserData.IsRootUser)), GetUserID(), userConfig); var result = _config.SaveUserConfig(User, userConfig);
return Json(result); return Json(result);
} }
public IActionResult Privacy() public IActionResult Privacy()

View File

@ -27,7 +27,7 @@ namespace CarCareTracker.Controllers
private readonly IUpgradeRecordDataAccess _upgradeRecordDataAccess; private readonly IUpgradeRecordDataAccess _upgradeRecordDataAccess;
private readonly IWebHostEnvironment _webEnv; private readonly IWebHostEnvironment _webEnv;
private readonly bool _useDescending; private readonly bool _useDescending;
private readonly IConfiguration _config; private readonly IConfigHelper _config;
private readonly IFileHelper _fileHelper; private readonly IFileHelper _fileHelper;
private readonly IGasHelper _gasHelper; private readonly IGasHelper _gasHelper;
private readonly IReminderHelper _reminderHelper; private readonly IReminderHelper _reminderHelper;
@ -49,7 +49,7 @@ namespace CarCareTracker.Controllers
IUpgradeRecordDataAccess upgradeRecordDataAccess, IUpgradeRecordDataAccess upgradeRecordDataAccess,
IUserLogic userLogic, IUserLogic userLogic,
IWebHostEnvironment webEnv, IWebHostEnvironment webEnv,
IConfiguration config) IConfigHelper config)
{ {
_logger = logger; _logger = logger;
_dataAccess = dataAccess; _dataAccess = dataAccess;
@ -67,7 +67,7 @@ namespace CarCareTracker.Controllers
_userLogic = userLogic; _userLogic = userLogic;
_webEnv = webEnv; _webEnv = webEnv;
_config = config; _config = config;
_useDescending = bool.Parse(config[nameof(UserConfig.UseDescending)]); _useDescending = config.GetUserConfig(User).UseDescending;
} }
private int GetUserID() private int GetUserID()
{ {
@ -231,8 +231,8 @@ namespace CarCareTracker.Controllers
var fileNameToExport = $"temp/{Guid.NewGuid()}.csv"; var fileNameToExport = $"temp/{Guid.NewGuid()}.csv";
var fullExportFilePath = _fileHelper.GetFullFilePath(fileNameToExport, false); var fullExportFilePath = _fileHelper.GetFullFilePath(fileNameToExport, false);
var vehicleRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId); var vehicleRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId);
bool useMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]); bool useMPG = _config.GetUserConfig(User).UseMPG;
bool useUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]); bool useUKMPG = _config.GetUserConfig(User).UseUKMPG;
vehicleRecords = vehicleRecords.OrderBy(x => x.Date).ThenBy(x => x.Mileage).ToList(); vehicleRecords = vehicleRecords.OrderBy(x => x.Date).ThenBy(x => x.Mileage).ToList();
var convertedRecords = _gasHelper.GetGasRecordViewModels(vehicleRecords, useMPG, useUKMPG); var convertedRecords = _gasHelper.GetGasRecordViewModels(vehicleRecords, useMPG, useUKMPG);
var exportData = convertedRecords.Select(x => new GasRecordExportModel { Date = x.Date.ToString(), Cost = x.Cost.ToString(), FuelConsumed = x.Gallons.ToString(), FuelEconomy = x.MilesPerGallon.ToString(), Odometer = x.Mileage.ToString() }); var exportData = convertedRecords.Select(x => new GasRecordExportModel { Date = x.Date.ToString(), Cost = x.Cost.ToString(), FuelConsumed = x.Gallons.ToString(), FuelEconomy = x.MilesPerGallon.ToString(), Odometer = x.Mileage.ToString() });
@ -389,8 +389,8 @@ namespace CarCareTracker.Controllers
//need it in ascending order to perform computation. //need it in ascending order to perform computation.
result = result.OrderBy(x => x.Date).ThenBy(x => x.Mileage).ToList(); result = result.OrderBy(x => x.Date).ThenBy(x => x.Mileage).ToList();
//check if the user uses MPG or Liters per 100km. //check if the user uses MPG or Liters per 100km.
bool useMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]); bool useMPG = _config.GetUserConfig(User).UseMPG;
bool useUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]); bool useUKMPG = _config.GetUserConfig(User).UseUKMPG;
var computedResults = _gasHelper.GetGasRecordViewModels(result, useMPG, useUKMPG); var computedResults = _gasHelper.GetGasRecordViewModels(result, useMPG, useUKMPG);
if (_useDescending) if (_useDescending)
{ {
@ -753,8 +753,8 @@ namespace CarCareTracker.Controllers
var upgradeRecords = _upgradeRecordDataAccess.GetUpgradeRecordsByVehicleId(vehicleId); var upgradeRecords = _upgradeRecordDataAccess.GetUpgradeRecordsByVehicleId(vehicleId);
var taxRecords = _taxRecordDataAccess.GetTaxRecordsByVehicleId(vehicleId); var taxRecords = _taxRecordDataAccess.GetTaxRecordsByVehicleId(vehicleId);
var gasRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId); var gasRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId);
bool useMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]); bool useMPG = _config.GetUserConfig(User).UseMPG;
bool useUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]); bool useUKMPG = _config.GetUserConfig(User).UseUKMPG;
vehicleHistory.TotalGasCost = gasRecords.Sum(x => x.Cost); vehicleHistory.TotalGasCost = gasRecords.Sum(x => x.Cost);
vehicleHistory.TotalCost = serviceRecords.Sum(x => x.Cost) + repairRecords.Sum(x => x.Cost) + upgradeRecords.Sum(x => x.Cost) + taxRecords.Sum(x => x.Cost); vehicleHistory.TotalCost = serviceRecords.Sum(x => x.Cost) + repairRecords.Sum(x => x.Cost) + upgradeRecords.Sum(x => x.Cost) + taxRecords.Sum(x => x.Cost);
var averageMPG = 0.00M; var averageMPG = 0.00M;

View File

@ -23,7 +23,8 @@ namespace CarCareTracker.External.Implementations
using (var db = new LiteDatabase(dbName)) using (var db = new LiteDatabase(dbName))
{ {
var table = db.GetCollection<UserConfigData>(tableName); var table = db.GetCollection<UserConfigData>(tableName);
return table.Upsert(userConfigData); table.Upsert(userConfigData);
return true;
}; };
} }
public bool DeleteUserConfig(int userId) public bool DeleteUserConfig(int userId)

View File

@ -1,5 +1,6 @@
using CarCareTracker.External.Interfaces; using CarCareTracker.External.Interfaces;
using CarCareTracker.Models; using CarCareTracker.Models;
using Microsoft.Extensions.Caching.Memory;
using System.Security.Claims; using System.Security.Claims;
namespace CarCareTracker.Helper namespace CarCareTracker.Helper
@ -7,20 +8,31 @@ namespace CarCareTracker.Helper
public interface IConfigHelper public interface IConfigHelper
{ {
UserConfig GetUserConfig(ClaimsPrincipal user); UserConfig GetUserConfig(ClaimsPrincipal user);
bool SaveUserConfig(bool isRootUser, int userId, UserConfig configData); bool SaveUserConfig(ClaimsPrincipal user, UserConfig configData);
public bool DeleteUserConfig(int userId); public bool DeleteUserConfig(int userId);
} }
public class ConfigHelper : IConfigHelper public class ConfigHelper : IConfigHelper
{ {
private readonly IConfiguration _config; private readonly IConfiguration _config;
private readonly IUserConfigDataAccess _userConfig; private readonly IUserConfigDataAccess _userConfig;
public ConfigHelper(IConfiguration serverConfig, IUserConfigDataAccess userConfig) private IMemoryCache _cache;
public ConfigHelper(IConfiguration serverConfig,
IUserConfigDataAccess userConfig,
IMemoryCache memoryCache)
{ {
_config = serverConfig; _config = serverConfig;
_userConfig = userConfig; _userConfig = userConfig;
_cache = memoryCache;
} }
public bool SaveUserConfig(bool isRootUser, int userId, UserConfig configData) public bool SaveUserConfig(ClaimsPrincipal user, UserConfig configData)
{ {
var storedUserId = user.FindFirstValue(ClaimTypes.NameIdentifier);
int userId = 0;
if (storedUserId != null)
{
userId = int.Parse(storedUserId);
}
bool isRootUser = user.IsInRole(nameof(UserData.IsRootUser));
if (isRootUser) if (isRootUser)
{ {
try try
@ -46,6 +58,7 @@ namespace CarCareTracker.Helper
configData.UserPasswordHash = string.Empty; configData.UserPasswordHash = string.Empty;
} }
File.WriteAllText(StaticHelper.UserConfigPath, System.Text.Json.JsonSerializer.Serialize(configData)); File.WriteAllText(StaticHelper.UserConfigPath, System.Text.Json.JsonSerializer.Serialize(configData));
_cache.Set<UserConfig>($"userConfig_{userId}", configData);
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
@ -60,46 +73,65 @@ namespace CarCareTracker.Helper
UserConfig = configData UserConfig = configData
}; };
var result = _userConfig.SaveUserConfig(userConfig); var result = _userConfig.SaveUserConfig(userConfig);
_cache.Set<UserConfig>($"userConfig_{userId}", configData);
return result; return result;
} }
} }
public bool DeleteUserConfig(int userId) public bool DeleteUserConfig(int userId)
{ {
_cache.Remove($"userConfig_{userId}");
var result = _userConfig.DeleteUserConfig(userId); var result = _userConfig.DeleteUserConfig(userId);
return result; return result;
} }
public UserConfig GetUserConfig(ClaimsPrincipal user) public UserConfig GetUserConfig(ClaimsPrincipal user)
{ {
var serverConfig = new UserConfig int userId = 0;
if (user != null)
{ {
EnableCsvImports = bool.Parse(_config[nameof(UserConfig.EnableCsvImports)]), var storedUserId = user.FindFirstValue(ClaimTypes.NameIdentifier);
UseDarkMode = bool.Parse(_config[nameof(UserConfig.UseDarkMode)]), if (storedUserId != null)
UseMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]), {
UseDescending = bool.Parse(_config[nameof(UserConfig.UseDescending)]), userId = int.Parse(storedUserId);
EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]), }
HideZero = bool.Parse(_config[nameof(UserConfig.HideZero)]),
UseUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)])
};
if (!user.Identity.IsAuthenticated)
{
return serverConfig;
}
bool isRootUser = user.IsInRole(nameof(UserData.IsRootUser));
int userId = int.Parse(user.FindFirstValue(ClaimTypes.NameIdentifier));
if (isRootUser)
{
return serverConfig;
} else } else
{ {
var result = _userConfig.GetUserConfig(userId); return new UserConfig();
if (result == null) }
return _cache.GetOrCreate<UserConfig>($"userConfig_{userId}", entry =>
{
entry.SlidingExpiration = TimeSpan.FromHours(1);
var serverConfig = new UserConfig
{
EnableCsvImports = bool.Parse(_config[nameof(UserConfig.EnableCsvImports)]),
UseDarkMode = bool.Parse(_config[nameof(UserConfig.UseDarkMode)]),
UseMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]),
UseDescending = bool.Parse(_config[nameof(UserConfig.UseDescending)]),
EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]),
HideZero = bool.Parse(_config[nameof(UserConfig.HideZero)]),
UseUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)])
};
if (!user.Identity.IsAuthenticated)
{ {
return serverConfig; return serverConfig;
} else
{
return result.UserConfig;
} }
} bool isRootUser = user.IsInRole(nameof(UserData.IsRootUser));
if (isRootUser)
{
return serverConfig;
}
else
{
var result = _userConfig.GetUserConfig(userId);
if (result == null)
{
return serverConfig;
}
else
{
return result.UserConfig;
}
}
});
} }
} }
} }

View File

@ -19,6 +19,7 @@ namespace CarCareTracker.Logic
OperationResponse ResetPasswordByUser(LoginModel credentials); OperationResponse ResetPasswordByUser(LoginModel credentials);
OperationResponse ResetUserPassword(LoginModel credentials); OperationResponse ResetUserPassword(LoginModel credentials);
UserData ValidateUserCredentials(LoginModel credentials); UserData ValidateUserCredentials(LoginModel credentials);
bool CheckIfUserIsValid(int userId);
bool CreateRootUserCredentials(LoginModel credentials); bool CreateRootUserCredentials(LoginModel credentials);
bool DeleteRootUserCredentials(); bool DeleteRootUserCredentials();
List<UserData> GetAllUsers(); List<UserData> GetAllUsers();
@ -36,6 +37,21 @@ namespace CarCareTracker.Logic
_tokenData = tokenData; _tokenData = tokenData;
_mailHelper = mailHelper; _mailHelper = mailHelper;
} }
public bool CheckIfUserIsValid(int userId)
{
if (userId == -1)
{
return true;
}
var result = _userData.GetUserRecordById(userId);
if (result == null)
{
return false;
} else
{
return result.Id != 0;
}
}
//handles user registration //handles user registration
public OperationResponse RegisterNewUser(LoginModel credentials) public OperationResponse RegisterNewUser(LoginModel credentials)
{ {

View File

@ -113,11 +113,17 @@ namespace CarCareTracker.Middleware
} }
else else
{ {
if (!_loginLogic.CheckIfUserIsValid(authCookie.UserData.Id))
{
return AuthenticateResult.Fail("Cookie points to non-existant user.");
}
//validate if user is still valid
var appIdentity = new ClaimsIdentity("Custom"); var appIdentity = new ClaimsIdentity("Custom");
var userIdentity = new List<Claim> var userIdentity = new List<Claim>
{ {
new(ClaimTypes.Name, authCookie.UserData.UserName), new(ClaimTypes.Name, authCookie.UserData.UserName),
new(ClaimTypes.NameIdentifier, authCookie.UserData.Id.ToString()) new(ClaimTypes.NameIdentifier, authCookie.UserData.Id.ToString()),
new(ClaimTypes.Role, "CookieAuth")
}; };
if (authCookie.UserData.IsAdmin) if (authCookie.UserData.IsAdmin)
{ {

View File

@ -1,6 +1,7 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var enableAuth = bool.Parse(Configuration[nameof(UserConfig.EnableAuth)]); var enableAuth = config.GetUserConfig(User).EnableAuth;
} }
@model string @model string
@{ @{
@ -17,7 +18,7 @@
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-gear me-2"></i>Settings</span></button> <button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-gear me-2"></i>Settings</span></button>
</li> </li>
@if (enableAuth) @if (User.IsInRole("CookieAuth"))
{ {
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link" onclick="performLogOut()"><span class="display-3 ms-2"><i class="bi bi-box-arrow-right me-2"></i>Logout</span></button> <button class="nav-link" onclick="performLogOut()"><span class="display-3 ms-2"><i class="bi bi-box-arrow-right me-2"></i>Logout</span></button>
@ -42,7 +43,7 @@
<li class="nav-item ms-auto" role="presentation"> <li class="nav-item ms-auto" role="presentation">
<button class="nav-link @(Model == "settings" ? "active" : "")" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><i class="bi bi-gear me-2"></i>Settings</button> <button class="nav-link @(Model == "settings" ? "active" : "")" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><i class="bi bi-gear me-2"></i>Settings</button>
</li> </li>
@if (enableAuth) @if (User.IsInRole("CookieAuth"))
{ {
<li class="nav-item"> <li class="nav-item">
<button class="nav-link" onclick="performLogOut()"><i class="bi bi-box-arrow-right me-2"></i>Logout</button> <button class="nav-link" onclick="performLogOut()"><i class="bi bi-box-arrow-right me-2"></i>Logout</button>
@ -69,6 +70,5 @@
</div> </div>
<script> <script>
loadGarage(); loadGarage();
loadSettings();
bindWindowResize(); bindWindowResize();
</script> </script>

View File

@ -1,7 +1,8 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
} }
@model List<CollisionRecord> @model List<CollisionRecord>
<div class="row"> <div class="row">

View File

@ -1,10 +1,11 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@model GasRecordViewModelContainer @model GasRecordViewModelContainer
@{ @{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]); var useMPG = config.GetUserConfig(User).UseMPG;
var useUKMPG = bool.Parse(Configuration[nameof(UserConfig.UseUKMPG)]); var useUKMPG = config.GetUserConfig(User).UseUKMPG;
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
var useKwh = Model.UseKwh; var useKwh = Model.UseKwh;
string consumptionUnit; string consumptionUnit;
string fuelEconomyUnit; string fuelEconomyUnit;

View File

@ -1,8 +1,9 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@model GasRecordInputContainer @model GasRecordInputContainer
@{ @{
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]); var useMPG = config.GetUserConfig(User).UseMPG;
var useUKMPG = bool.Parse(Configuration[nameof(UserConfig.UseUKMPG)]); var useUKMPG = config.GetUserConfig(User).UseUKMPG;
var useKwh = Model.UseKwh; var useKwh = Model.UseKwh;
var isNew = Model.GasRecord.Id == 0; var isNew = Model.GasRecord.Id == 0;
string consumptionUnit; string consumptionUnit;

View File

@ -1,7 +1,8 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
} }
@model List<ServiceRecord> @model List<ServiceRecord>
<div class="row"> <div class="row">

View File

@ -1,7 +1,8 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
} }
@model List<TaxRecord> @model List<TaxRecord>
<div class="row"> <div class="row">

View File

@ -1,7 +1,8 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
} }
@model List<UpgradeRecord> @model List<UpgradeRecord>
<div class="row"> <div class="row">

View File

@ -1,8 +1,9 @@
@inject IConfiguration Configuration @using CarCareTracker.Helper
@inject IConfigHelper config
@{ @{
var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var hideZero = config.GetUserConfig(User).HideZero;
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]); var useMPG = config.GetUserConfig(User).UseMPG;
var useUKMPG = bool.Parse(Configuration[nameof(UserConfig.UseUKMPG)]); var useUKMPG = config.GetUserConfig(User).UseUKMPG;
var useKwh = Model.VehicleData.IsElectric; var useKwh = Model.VehicleData.IsElectric;
string fuelEconomyUnit; string fuelEconomyUnit;
if (useKwh) if (useKwh)

View File

@ -14,6 +14,7 @@ function hideAddVehicleModal() {
function loadGarage() { function loadGarage() {
$.get('/Home/Garage', function (data) { $.get('/Home/Garage', function (data) {
$("#garageContainer").html(data); $("#garageContainer").html(data);
loadSettings();
}); });
} }
function loadSettings() { function loadSettings() {