refact
This commit is contained in:
parent
7da74b0dfb
commit
504f431937
67 changed files with 239 additions and 96 deletions
|
|
@ -8,8 +8,8 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NuGet.Versioning;
|
||||
using isn.Data;
|
||||
using isn.Entities;
|
||||
using isnd.Data;
|
||||
using isnd.Entities;
|
||||
using Unleash.ClientFactory;
|
||||
using Unleash;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -17,8 +17,10 @@ using isnd.Services;
|
|||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using isnd.Helpers;
|
||||
using isnd.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace isn.Controllers
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
@ -60,6 +62,42 @@ namespace isn.Controllers
|
|||
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
|
||||
|
||||
|
||||
// GET: PackageVersion
|
||||
public async Task<IActionResult> Index(PackageIndexViewModel model)
|
||||
{
|
||||
var applicationDbContext = _dbContext.Packages.Include(p => p.Versions).Where(
|
||||
p => ( model.Prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
||||
&& ((model.query == null) || p.Id.StartsWith(model.query)));
|
||||
model.data = await applicationDbContext.ToArrayAsync();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// GET: PackageVersion/Details/5
|
||||
public async Task<IActionResult> Details(string pkgid)
|
||||
{
|
||||
if (pkgid == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packageVersion = _dbContext.PackageVersions
|
||||
.Include(p => p.Package)
|
||||
.Where(m => m.PackageId == pkgid)
|
||||
.OrderByDescending(p => p)
|
||||
;
|
||||
|
||||
if (packageVersion == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
bool results = await packageVersion.AnyAsync();
|
||||
var latest = await packageVersion.FirstAsync();
|
||||
|
||||
return View("Details", new PackageDetailViewModel { latest = latest, pkgid = pkgid, totalHits = packageVersion.Count(), data = packageVersion.Take(10).ToArray() } );
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("~/index.json")]
|
||||
public IActionResult ApiIndex()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue