From 753f54dad074357048365f141233de65b68b0eba Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 2 Nov 2024 15:33:46 +0000 Subject: [PATCH] Home index --- src/isnd/Controllers/HomeController.cs | 13 +++++++++++-- src/isnd/Controllers/Packages/ApiIndex.cs | 2 +- src/isnd/ViewModels/HomeIndexViewModel.cs | 2 ++ src/isnd/Views/Home/Index.cshtml | 8 +++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/isnd/Controllers/HomeController.cs b/src/isnd/Controllers/HomeController.cs index 6c3836b..b811535 100644 --- a/src/isnd/Controllers/HomeController.cs +++ b/src/isnd/Controllers/HomeController.cs @@ -6,6 +6,10 @@ using System.Linq; using isnd.ViewModels; using System.Reflection; using Microsoft.EntityFrameworkCore; +using Microsoft.Build.Logging; +using Microsoft.Extensions.Options; +using isnd.Entities; +using isn.abst; namespace isnd.Controllers { @@ -15,14 +19,18 @@ namespace isnd.Controllers public class HomeController : Controller { private readonly ApplicationDbContext _dbContext; + private readonly IsndSettings _isndSettings; + /// /// Home controller ctor /// /// + /// public HomeController( - ApplicationDbContext dbContext) + ApplicationDbContext dbContext, IOptions isndSettings) { _dbContext = dbContext; + _isndSettings = isndSettings.Value; } public IActionResult Index() @@ -30,7 +38,8 @@ namespace isnd.Controllers return View(new HomeIndexViewModel{ PkgCount = _dbContext.Packages .Where(p => p.Versions.Count > 0) - .Count()}); + .Count(), + APIUrl = _isndSettings.ExternalUrl + Constants.ApiVersionPrefix + ApiConfig.Index}); } public IActionResult About() diff --git a/src/isnd/Controllers/Packages/ApiIndex.cs b/src/isnd/Controllers/Packages/ApiIndex.cs index bb88187..44ca507 100644 --- a/src/isnd/Controllers/Packages/ApiIndex.cs +++ b/src/isnd/Controllers/Packages/ApiIndex.cs @@ -33,7 +33,7 @@ namespace isnd.Controllers [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Index)] public IActionResult ApiIndex() { - return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl + "/index.json"){ Version = PackageManager.BASE_API_LEVEL, Resources = resources }); + return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl + ApiConfig.Index){ Version = PackageManager.BASE_API_LEVEL, Resources = resources }); } } diff --git a/src/isnd/ViewModels/HomeIndexViewModel.cs b/src/isnd/ViewModels/HomeIndexViewModel.cs index d4dead9..cebb907 100644 --- a/src/isnd/ViewModels/HomeIndexViewModel.cs +++ b/src/isnd/ViewModels/HomeIndexViewModel.cs @@ -5,5 +5,7 @@ namespace isnd.ViewModels { public int PkgCount { get; set; } + public string APIUrl { get; set; } + } } \ No newline at end of file diff --git a/src/isnd/Views/Home/Index.cshtml b/src/isnd/Views/Home/Index.cshtml index 8d710a7..748ae06 100644 --- a/src/isnd/Views/Home/Index.cshtml +++ b/src/isnd/Views/Home/Index.cshtml @@ -1,8 +1,10 @@ @model HomeIndexViewModel @{ - ViewData["Title"] = "Home Page"; + ViewData["Title"] = "Packages"; }
-

Bom

-

'Key!

+

@ViewData["Title"]

+

+

Nuget API v3 : + @Model.APIUrl

\ No newline at end of file