pkg upd by no db

broken/ef
Paul Schneider 3 years ago
parent bd1c47e7c6
commit 58750587d0
4 changed files with 42 additions and 12 deletions

@ -22,10 +22,10 @@ namespace isn
// GET: PackageVersion
public async Task<IActionResult> Index(PackageVersionIndexViewModel model)
{
var applicationDbContext = _context.PackageVersions.Include(p => p.Package).Where(p => p.PackageId.StartsWith(model.PackageId));
var applicationDbContext = _context.PackageVersions.Include(p => p.Package).Where(
p => ( model.Prerelease || p.IsPrerelease)
&& ((model.PackageId == null) || p.PackageId.StartsWith(model.PackageId)));
model.Versions = await applicationDbContext.ToArrayAsync();
return View(model);
}

@ -104,14 +104,26 @@ namespace isn.Controllers
var destdir = new DirectoryInfo(dest.DirectoryName);
if (dest.Exists)
{
// La version existe sur le disque,
// mais si elle ne l'est pas en base de donnéés,
// on remplace la version sur disque.
var pkgv = _dbContext.PackageVersions.Where(
v => v.PackageId == package.Id
);
if (pkgv !=null && pkgv.Count()==0)
{
dest.Delete();
}
else {
ViewData["msg"] = "existant";
ViewData["ecode"] = 1;
_logger.LogWarning("400 : existant");
return base.BadRequest(new { error = ModelState });
}
else
}
{
destdir.Create();
if (!destdir.Exists) destdir.Create();
source.MoveTo(fullpath);
files.Add(name);
string fullstringversion = version.ToFullString();
@ -156,7 +168,12 @@ namespace isn.Controllers
}
}
}
nuspec.ExtractToFile(Path.Combine(pkgpath, pkgid + ".nuspec"));
string nuspecfullpath = Path.Combine(pkgpath, pkgid + ".nuspec");
FileInfo nfpi = new FileInfo(nuspecfullpath);
if (nfpi.Exists)
nfpi.Delete();
nuspec.ExtractToFile(nuspecfullpath);
}
}

@ -2,6 +2,8 @@ using System.Collections.Generic;
using System.Linq;
using isn.Controllers;
using isn.Data;
using isn.ViewModels;
using isnd.ViewModels;
using Microsoft.EntityFrameworkCore;
using NuGet.Versioning;
using Unleash;
@ -15,7 +17,7 @@ namespace isnd.Services
{
this.dbContext = dbContext;
}
public IndexResult SearchByName(string query,
public PackageIndexViewModel SearchByName(string query,
int skip, int take,bool prerelease = false,
string packageType = null)
{
@ -30,7 +32,7 @@ namespace isnd.Services
var total = scope.Count();
var pkgs = scope.Skip(skip).Take(take).ToArray();
return new IndexResult
return new PackageIndexViewModel
{
totalHits = total,
data = pkgs

@ -0,0 +1,11 @@
using isn.Data;
namespace isnd.ViewModels
{
public class PackageIndexViewModel
{
public Package[] data {get; set;}
public string Query { get; set; }
public int totalHits { get; internal set; }
}
}
Loading…