Web search result fixed
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Entities;
|
||||
@ -18,16 +20,26 @@ namespace isnd.ViewModels
|
||||
return result;
|
||||
}
|
||||
|
||||
private IEnumerable<Package> result;
|
||||
private IEnumerable<Package> result=null;
|
||||
|
||||
[JsonIgnore]
|
||||
public string ApiBase{get; private set;}
|
||||
|
||||
public PackageSearchResult(string apiBase)
|
||||
{
|
||||
// empty result
|
||||
this.ApiBase = apiBase;
|
||||
|
||||
}
|
||||
|
||||
public PackageSearchResult(IEnumerable<Package> result, string apiBase, int totalHit)
|
||||
{
|
||||
|
||||
this.result = result;
|
||||
this.ApiBase = apiBase;
|
||||
data=result.Select(p=> NewPackageHit(apiBase, p)).ToArray();
|
||||
|
||||
data = (totalHit>0) ? result.Select(p=> NewPackageHit(apiBase, p)).ToArray()
|
||||
: new PackageHit[0];
|
||||
this.totalHits = totalHit;
|
||||
}
|
||||
|
||||
@ -37,11 +49,10 @@ namespace isnd.ViewModels
|
||||
var latest = package.GetLatestVersion();
|
||||
if (latest==null) return null;
|
||||
|
||||
var pkgHit = new PackageHit(regId, package.Id)
|
||||
{
|
||||
version = latest.NugetVersion.ToString(),
|
||||
description = latest.Description,
|
||||
};
|
||||
var pkgHit = new PackageHit(regId, package.Id,
|
||||
latest.NugetVersion.ToString(),
|
||||
latest.Description);
|
||||
|
||||
if (package.Versions!=null)
|
||||
{
|
||||
pkgHit.versions = package.Versions
|
||||
@ -52,8 +63,8 @@ namespace isnd.ViewModels
|
||||
return pkgHit;
|
||||
}
|
||||
|
||||
public PackageHit[] data { get; protected set; }
|
||||
public PackageHit[] data { get; protected set; } = [];
|
||||
|
||||
public int totalHits { get; set; }
|
||||
public int totalHits { get; set; } = 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user