Home index

This commit is contained in:
2024-11-02 15:33:46 +00:00
parent 72ecf30458
commit 753f54dad0
4 changed files with 19 additions and 6 deletions

View File

@ -6,6 +6,10 @@ using System.Linq;
using isnd.ViewModels; using isnd.ViewModels;
using System.Reflection; using System.Reflection;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Build.Logging;
using Microsoft.Extensions.Options;
using isnd.Entities;
using isn.abst;
namespace isnd.Controllers namespace isnd.Controllers
{ {
@ -15,14 +19,18 @@ namespace isnd.Controllers
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ApplicationDbContext _dbContext; private readonly ApplicationDbContext _dbContext;
private readonly IsndSettings _isndSettings;
/// <summary> /// <summary>
/// Home controller ctor /// Home controller ctor
/// </summary> /// </summary>
/// <param name="dbContext"></param> /// <param name="dbContext"></param>
/// <param name="isndSettings"></param>
public HomeController( public HomeController(
ApplicationDbContext dbContext) ApplicationDbContext dbContext, IOptions<IsndSettings> isndSettings)
{ {
_dbContext = dbContext; _dbContext = dbContext;
_isndSettings = isndSettings.Value;
} }
public IActionResult Index() public IActionResult Index()
@ -30,7 +38,8 @@ namespace isnd.Controllers
return View(new HomeIndexViewModel{ return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages PkgCount = _dbContext.Packages
.Where(p => p.Versions.Count > 0) .Where(p => p.Versions.Count > 0)
.Count()}); .Count(),
APIUrl = _isndSettings.ExternalUrl + Constants.ApiVersionPrefix + ApiConfig.Index});
} }
public IActionResult About() public IActionResult About()

View File

@ -33,7 +33,7 @@ namespace isnd.Controllers
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Index)] [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Index)]
public IActionResult ApiIndex() 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 });
} }
} }

View File

@ -5,5 +5,7 @@ namespace isnd.ViewModels
{ {
public int PkgCount { get; set; } public int PkgCount { get; set; }
public string APIUrl { get; set; }
} }
} }

View File

@ -1,8 +1,10 @@
@model HomeIndexViewModel @model HomeIndexViewModel
@{ @{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Packages";
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Bom</h1> <h1 class="display-4">@ViewData["Title"]</h1>
<p>'Key!</p> <p></p>
<p>Nuget API v3 :
<a href="@Model.APIUrl"><code>@Model.APIUrl</code></a></p>
</div> </div>