A valid package index page
This commit is contained in:
parent
88c8480911
commit
58f77a06ea
15 changed files with 210 additions and 153 deletions
|
|
@ -11,35 +11,10 @@ namespace isnd.Helpers
|
|||
{
|
||||
public static class PackageVersionHelpers
|
||||
{
|
||||
|
||||
public static bool IsOwner(this ClaimsPrincipal user, PackageVersion v)
|
||||
{
|
||||
var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return v.Package.OwnerId == userId;
|
||||
}
|
||||
|
||||
public static RegistrationPageIndex CreateRegistrationPages(this IEnumerable<RegistrationLeaf> leaves,
|
||||
string bid)
|
||||
{
|
||||
List<RegistrationPage> pages = new List<RegistrationPage>();
|
||||
var ids = leaves.Select(l => l.Entry.Id).Distinct().ToArray();
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var lbi = leaves.Where(l=>l.Entry.Id == id).OrderBy(l=>
|
||||
new Version(l.Entry.version));
|
||||
var latest = new Version(lbi.Last().Entry.version);
|
||||
pages.Add(new RegistrationPage(bid + id + "/" + latest.Major + "."
|
||||
+ latest.Minor + "."
|
||||
+ latest.Build)
|
||||
{
|
||||
Count = lbi.Count(),
|
||||
Lower = new Version(lbi.First().Entry.version),
|
||||
Upper = latest,
|
||||
Items = lbi.ToList(),
|
||||
Parent = bid + id + "/" + ApiConfig.IndexDotJson,
|
||||
});
|
||||
}
|
||||
return new RegistrationPageIndex(pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue