From 47657c009326b06d87fb46901bbbc7df401add74 Mon Sep 17 00:00:00 2001
From: "DESKTOP-T0O5CDB\\DESK-555BD"
Date: Tue, 21 May 2024 15:29:46 -0600
Subject: [PATCH] Added sponsor section.
---
Controllers/HomeController.cs | 12 ++++-
Helper/StaticHelper.cs | 2 +-
Models/Settings/SettingsViewModel.cs | 1 +
Models/Sponsors.cs | 10 ++++
Views/Home/_Settings.cshtml | 3 +-
Views/Home/_Sponsors.cshtml | 73 ++++++++++++++++++++++++++++
wwwroot/defaults/en_US.json | 2 +-
7 files changed, 99 insertions(+), 4 deletions(-)
create mode 100644 Models/Sponsors.cs
create mode 100644 Views/Home/_Sponsors.cshtml
diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs
index be13b9e..60e4e13 100644
--- a/Controllers/HomeController.cs
+++ b/Controllers/HomeController.cs
@@ -105,7 +105,7 @@ namespace CarCareTracker.Controllers
var reminderUrgency = _reminderHelper.GetReminderRecordViewModels(new List { reminder }, 0, DateTime.Now).FirstOrDefault();
return PartialView("_ReminderRecordCalendarModal", reminderUrgency);
}
- public IActionResult Settings()
+ public async Task Settings()
{
var userConfig = _config.GetUserConfig(User);
var languages = _fileHelper.GetLanguages();
@@ -114,6 +114,16 @@ namespace CarCareTracker.Controllers
UserConfig = userConfig,
UILanguages = languages
};
+ try
+ {
+ var httpClient = new HttpClient();
+ var sponsorsData = await httpClient.GetFromJsonAsync(StaticHelper.SponsorsPath) ?? new Sponsors();
+ viewModel.Sponsors = sponsorsData;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"Unable to retrieve sponsors: {ex.Message}");
+ }
return PartialView("_Settings", viewModel);
}
[HttpPost]
diff --git a/Helper/StaticHelper.cs b/Helper/StaticHelper.cs
index 5b15265..c2254c8 100644
--- a/Helper/StaticHelper.cs
+++ b/Helper/StaticHelper.cs
@@ -14,7 +14,7 @@ namespace CarCareTracker.Helper
public static string GenericErrorMessage = "An error occurred, please try again later";
public static string ReminderEmailTemplate = "defaults/reminderemailtemplate.txt";
public static string DefaultAllowedFileExtensions = ".png,.jpg,.jpeg,.pdf,.xls,.xlsx,.docx";
-
+ public static string SponsorsPath = "https://raw.githubusercontent.com/hargata/hargata/main/sponsors.json";
public static string GetTitleCaseReminderUrgency(ReminderUrgency input)
{
switch (input)
diff --git a/Models/Settings/SettingsViewModel.cs b/Models/Settings/SettingsViewModel.cs
index 58f23aa..09d914b 100644
--- a/Models/Settings/SettingsViewModel.cs
+++ b/Models/Settings/SettingsViewModel.cs
@@ -4,5 +4,6 @@ namespace CarCareTracker.Models
{
public UserConfig UserConfig { get; set; }
public List UILanguages { get; set; }
+ public Sponsors Sponsors { get; set; } = new Sponsors();
}
}
diff --git a/Models/Sponsors.cs b/Models/Sponsors.cs
new file mode 100644
index 0000000..38d6f37
--- /dev/null
+++ b/Models/Sponsors.cs
@@ -0,0 +1,10 @@
+namespace CarCareTracker.Models
+{
+ public class Sponsors
+ {
+ public List LifeTime { get; set; } = new List();
+ public List Bronze { get; set; } = new List();
+ public List Silver { get; set; } = new List();
+ public List Gold { get; set; } = new List();
+ }
+}
diff --git a/Views/Home/_Settings.cshtml b/Views/Home/_Settings.cshtml
index afa6e2a..074c653 100644
--- a/Views/Home/_Settings.cshtml
+++ b/Views/Home/_Settings.cshtml
@@ -219,7 +219,7 @@
If you enjoyed using this app, please consider spreading the good word.
- If you are a commercial user, or if you just want to support the development of this project, consider subscribing to our Patreon or make a donation
+ If you want to support the development of this project, consider subscribing to our Patreon or make a donation
Hometown Shoutout
@@ -251,6 +251,7 @@
+@await Html.PartialAsync("_Sponsors", Model.Sponsors)