Compilation warns
This commit is contained in:
61
src/isnd/Controllers/Packages/Catalog.cs
Normal file
61
src/isnd/Controllers/Packages/Catalog.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Catalog)]
|
||||
public IActionResult CatalogIndex()
|
||||
{
|
||||
return Ok(PackageManager.CurrentCatalogIndex);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogPage + "-{id}")]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string lower)
|
||||
{
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgVersion = await _dbContext.PackageVersions
|
||||
.Include(v => v.LatestCommit)
|
||||
.SingleOrDefaultAsync(
|
||||
v => v.PackageId == id &&
|
||||
v.FullString == lower &&
|
||||
v.Type == pkgType
|
||||
);
|
||||
if (pkgVersion == null) return NotFound();
|
||||
|
||||
var pub = await _dbContext.Commits
|
||||
.Include(c => c.Versions)
|
||||
.OrderBy(c => c.CommitTimeStamp)
|
||||
.SingleOrDefaultAsync
|
||||
(
|
||||
c => c.Action == PackageAction.PublishPackage
|
||||
&& c.Versions.Contains(pkgVersion)
|
||||
);
|
||||
return Ok(new CatalogLeaf
|
||||
{
|
||||
CommitId = id,
|
||||
Id = pkgVersion.PackageId,
|
||||
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user