From 504f431937a27dee6a657409456aea774da0e0dc Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 15 Aug 2021 19:09:01 +0100 Subject: [PATCH] refact --- .../Authorisation/ValidApiKeyRequirement.cs | 2 +- .../ValidApiKeyRequirementHandler.cs | 2 +- src/isnd/Constants.cs | 2 +- src/isnd/Controllers/AccountController.cs | 6 +-- src/isnd/Controllers/ApiKeysController.cs | 8 +-- src/isnd/Controllers/HomeController.cs | 8 +-- src/isnd/Controllers/NewUpdateController.cs | 4 +- .../Controllers/PackageVersionController.cs | 6 +-- .../Controllers/PackagesController.Put.cs | 6 +-- src/isnd/Controllers/PackagesController.cs | 44 +++++++++++++-- src/isnd/Controllers/Resource.cs | 2 +- src/isnd/Controllers/SafeNameAttribute.cs | 2 +- src/isnd/Data/Account/AccountOptions.cs | 2 +- src/isnd/Data/Account/ExternalProvider.cs | 2 +- src/isnd/Data/Account/LoggedOutViewModel.cs | 2 +- src/isnd/Data/Account/LoginInputModel.cs | 2 +- src/isnd/Data/Account/LoginViewModel.cs | 2 +- src/isnd/Data/Account/LogoutInputModel.cs | 2 +- src/isnd/Data/Account/LogoutViewModel.cs | 2 +- src/isnd/Data/Account/RedirectViewModel.cs | 2 +- src/isnd/Data/Account/RegisterViewModel.cs | 2 +- src/isnd/Data/ApiKeys/ApiKey.cs | 2 +- src/isnd/Data/ApiKeys/ApiKeyViewModel.cs | 2 +- src/isnd/Data/ApiKeys/CreateModel.cs | 2 +- src/isnd/Data/ApiKeys/DeleteModel.cs | 2 +- src/isnd/Data/ApiKeys/DetailModel.cs | 2 +- src/isnd/Data/ApiKeys/EditModel.cs | 2 +- src/isnd/Data/ApiKeys/IndexModel.cs | 2 +- src/isnd/Data/ApplicationDbContext.cs | 6 +-- src/isnd/Data/ApplicationUser.cs | 2 +- src/isnd/Data/NewReleaseInfo.cs | 2 +- src/isnd/Data/Package.cs | 2 +- src/isnd/Data/PackageVersion.cs | 2 +- src/isnd/Data/Roles/Administrator.cs | 2 +- src/isnd/Entities/NugetSettings.cs | 2 +- src/isnd/Entities/SmtpSettings.cs | 2 +- src/isnd/Extensions/Extensions.cs | 2 +- src/isnd/Helpers/NuspecCoreReaderHelpers.cs | 2 +- src/isnd/Interfaces/IMailer.cs | 2 +- .../20210424155323_init.Designer.cs | 2 +- .../20210502153508_api-keys.Designer.cs | 2 +- ...508012908_ApkiKey.CreationDate.Designer.cs | 2 +- .../20210516060430_packages.Designer.cs | 2 +- ...210522194803_packageVersionKey.Designer.cs | 2 +- .../20210621214109_version-types.Designer.cs | 2 +- .../ApplicationDbContextModelSnapshot.cs | 2 +- src/isnd/Program.cs | 2 +- src/isnd/Services/EmailSender.cs | 6 +-- src/isnd/Services/PackageManager.cs | 6 +-- src/isnd/Services/SearchResult.cs | 2 +- src/isnd/Startup.cs | 16 +++--- src/isnd/ViewModels/HomeIndexViewModel.cs | 2 +- src/isnd/ViewModels/PackageDetailViewModel.cs | 15 ++++++ src/isnd/ViewModels/PackageIndexViewModel.cs | 5 +- .../PackageVersionIndexViewModel.cs | 4 +- src/isnd/Views/ApiKeys/Create.cshtml | 2 +- src/isnd/Views/ApiKeys/Delete.cshtml | 2 +- src/isnd/Views/ApiKeys/Details.cshtml | 2 +- src/isnd/Views/ApiKeys/Edit.cshtml | 2 +- src/isnd/Views/ApiKeys/Index.cshtml | 2 +- src/isnd/Views/Home/Index.cshtml | 2 +- src/isnd/Views/PackageVersion/Delete.cshtml | 2 +- src/isnd/Views/PackageVersion/Details.cshtml | 2 +- src/isnd/Views/Packages/Details.cshtml | 37 +++++++++++++ src/isnd/Views/Packages/Index.cshtml | 53 +++++++++++++++++++ src/isnd/Views/_ViewImports.cshtml | 4 +- test/isnd.tests/UnitTestWebHost.cs | 3 +- 67 files changed, 239 insertions(+), 96 deletions(-) create mode 100644 src/isnd/ViewModels/PackageDetailViewModel.cs create mode 100644 src/isnd/Views/Packages/Details.cshtml create mode 100644 src/isnd/Views/Packages/Index.cshtml diff --git a/src/isnd/Authorisation/ValidApiKeyRequirement.cs b/src/isnd/Authorisation/ValidApiKeyRequirement.cs index f56ab79..0428de1 100644 --- a/src/isnd/Authorisation/ValidApiKeyRequirement.cs +++ b/src/isnd/Authorisation/ValidApiKeyRequirement.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authorization; -namespace isn.Authorization +namespace isnd.Authorization { internal class ValidApiKeyRequirement : IAuthorizationRequirement { diff --git a/src/isnd/Authorisation/ValidApiKeyRequirementHandler.cs b/src/isnd/Authorisation/ValidApiKeyRequirementHandler.cs index 12d35a0..846088c 100644 --- a/src/isnd/Authorisation/ValidApiKeyRequirementHandler.cs +++ b/src/isnd/Authorisation/ValidApiKeyRequirementHandler.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; -namespace isn.Authorization +namespace isnd.Authorization { internal class ValidApiKeyRequirementHandler : AuthorizationHandler { diff --git a/src/isnd/Constants.cs b/src/isnd/Constants.cs index f0017d1..0f1d372 100644 --- a/src/isnd/Constants.cs +++ b/src/isnd/Constants.cs @@ -1,4 +1,4 @@ -namespace isn +namespace isnd { public static class Constants { diff --git a/src/isnd/Controllers/AccountController.cs b/src/isnd/Controllers/AccountController.cs index 19ad443..2b728c7 100644 --- a/src/isnd/Controllers/AccountController.cs +++ b/src/isnd/Controllers/AccountController.cs @@ -7,14 +7,14 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -using isn.Data; -using isn.Data.Roles; +using isnd.Data; +using isnd.Data.Roles; using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -namespace isn.Controllers +namespace isnd.Controllers { [AllowAnonymous] public class AccountController : Controller diff --git a/src/isnd/Controllers/ApiKeysController.cs b/src/isnd/Controllers/ApiKeysController.cs index 36db0eb..bbc2d21 100644 --- a/src/isnd/Controllers/ApiKeysController.cs +++ b/src/isnd/Controllers/ApiKeysController.cs @@ -10,12 +10,12 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; -using isn.Data; -using isn.Entities; -using isn.Data.ApiKeys; +using isnd.Data; +using isnd.Entities; +using isnd.Data.ApiKeys; -namespace isn.Controllers +namespace isnd.Controllers { [Authorize] public class ApiKeysController : Controller diff --git a/src/isnd/Controllers/HomeController.cs b/src/isnd/Controllers/HomeController.cs index 6e37e7c..219ba4f 100644 --- a/src/isnd/Controllers/HomeController.cs +++ b/src/isnd/Controllers/HomeController.cs @@ -2,10 +2,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using isn.Entities; -using isn.Data; +using isnd.Entities; +using isnd.Data; using System.Linq; -using isn.ViewModels; +using isnd.ViewModels; using Unleash.ClientFactory; using Unleash; using isnd.Entities; @@ -13,7 +13,7 @@ using System; using System.Collections.Generic; using isnd.Helpers; -namespace isn.Controllers +namespace isnd.Controllers { public class HomeController : Controller { diff --git a/src/isnd/Controllers/NewUpdateController.cs b/src/isnd/Controllers/NewUpdateController.cs index e29e0e4..b5c5c44 100644 --- a/src/isnd/Controllers/NewUpdateController.cs +++ b/src/isnd/Controllers/NewUpdateController.cs @@ -1,9 +1,9 @@ using System; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using isn.Data; +using isnd.Data; -namespace isn.Controllers +namespace isnd.Controllers { public class NewUpdateController : Controller diff --git a/src/isnd/Controllers/PackageVersionController.cs b/src/isnd/Controllers/PackageVersionController.cs index cb328da..1ff06e0 100644 --- a/src/isnd/Controllers/PackageVersionController.cs +++ b/src/isnd/Controllers/PackageVersionController.cs @@ -4,10 +4,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using isn.Data; -using isn.ViewModels; +using isnd.Data; +using isnd.ViewModels; -namespace isn +namespace isnd { [AllowAnonymous] public class PackageVersionController : Controller diff --git a/src/isnd/Controllers/PackagesController.Put.cs b/src/isnd/Controllers/PackagesController.Put.cs index b5464d4..7be8a5f 100644 --- a/src/isnd/Controllers/PackagesController.Put.cs +++ b/src/isnd/Controllers/PackagesController.Put.cs @@ -11,11 +11,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using NuGet.Packaging.Core; using NuGet.Versioning; -using isn.Data; -using isn.Helpers; +using isnd.Data; +using isnd.Helpers; using Microsoft.AspNetCore.Http; -namespace isn.Controllers +namespace isnd.Controllers { public partial class PackagesController diff --git a/src/isnd/Controllers/PackagesController.cs b/src/isnd/Controllers/PackagesController.cs index d54d625..f680b58 100644 --- a/src/isnd/Controllers/PackagesController.cs +++ b/src/isnd/Controllers/PackagesController.cs @@ -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 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 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() { diff --git a/src/isnd/Controllers/Resource.cs b/src/isnd/Controllers/Resource.cs index 61497e8..437bb5d 100644 --- a/src/isnd/Controllers/Resource.cs +++ b/src/isnd/Controllers/Resource.cs @@ -1,4 +1,4 @@ -namespace isn.Controllers +namespace isnd.Controllers { internal class Resource { diff --git a/src/isnd/Controllers/SafeNameAttribute.cs b/src/isnd/Controllers/SafeNameAttribute.cs index 8c09f7d..b354173 100644 --- a/src/isnd/Controllers/SafeNameAttribute.cs +++ b/src/isnd/Controllers/SafeNameAttribute.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; using System.Linq; -namespace isn.Controllers +namespace isnd.Controllers { internal class SafeNameAttribute : ValidationAttribute { diff --git a/src/isnd/Data/Account/AccountOptions.cs b/src/isnd/Data/Account/AccountOptions.cs index c786bfc..d2290cc 100644 --- a/src/isnd/Data/Account/AccountOptions.cs +++ b/src/isnd/Data/Account/AccountOptions.cs @@ -4,7 +4,7 @@ using System; -namespace isn.Data +namespace isnd.Data { public class AccountOptions { diff --git a/src/isnd/Data/Account/ExternalProvider.cs b/src/isnd/Data/Account/ExternalProvider.cs index cf63a10..70781c3 100644 --- a/src/isnd/Data/Account/ExternalProvider.cs +++ b/src/isnd/Data/Account/ExternalProvider.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -namespace isn.Data +namespace isnd.Data { public class ExternalProvider { diff --git a/src/isnd/Data/Account/LoggedOutViewModel.cs b/src/isnd/Data/Account/LoggedOutViewModel.cs index b6a3e3f..61f68ae 100644 --- a/src/isnd/Data/Account/LoggedOutViewModel.cs +++ b/src/isnd/Data/Account/LoggedOutViewModel.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -namespace isn.Data +namespace isnd.Data { public class LoggedOutViewModel { diff --git a/src/isnd/Data/Account/LoginInputModel.cs b/src/isnd/Data/Account/LoginInputModel.cs index 0cfcfb3..e87909c 100644 --- a/src/isnd/Data/Account/LoginInputModel.cs +++ b/src/isnd/Data/Account/LoginInputModel.cs @@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations; -namespace isn.Data +namespace isnd.Data { public class LoginInputModel { diff --git a/src/isnd/Data/Account/LoginViewModel.cs b/src/isnd/Data/Account/LoginViewModel.cs index 3f867c6..d641fe8 100644 --- a/src/isnd/Data/Account/LoginViewModel.cs +++ b/src/isnd/Data/Account/LoginViewModel.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace isn.Data +namespace isnd.Data { public class LoginViewModel : LoginInputModel { diff --git a/src/isnd/Data/Account/LogoutInputModel.cs b/src/isnd/Data/Account/LogoutInputModel.cs index 7ea7160..3200b8e 100644 --- a/src/isnd/Data/Account/LogoutInputModel.cs +++ b/src/isnd/Data/Account/LogoutInputModel.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -namespace isn.Data +namespace isnd.Data { public class LogoutInputModel { diff --git a/src/isnd/Data/Account/LogoutViewModel.cs b/src/isnd/Data/Account/LogoutViewModel.cs index 26a28be..4f24c46 100644 --- a/src/isnd/Data/Account/LogoutViewModel.cs +++ b/src/isnd/Data/Account/LogoutViewModel.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -namespace isn.Data +namespace isnd.Data { public class LogoutViewModel : LogoutInputModel { diff --git a/src/isnd/Data/Account/RedirectViewModel.cs b/src/isnd/Data/Account/RedirectViewModel.cs index 017c576..52a3961 100644 --- a/src/isnd/Data/Account/RedirectViewModel.cs +++ b/src/isnd/Data/Account/RedirectViewModel.cs @@ -3,7 +3,7 @@ -namespace isn.Data +namespace isnd.Data { public class RedirectViewModel { diff --git a/src/isnd/Data/Account/RegisterViewModel.cs b/src/isnd/Data/Account/RegisterViewModel.cs index d7e131b..23a8c7c 100644 --- a/src/isnd/Data/Account/RegisterViewModel.cs +++ b/src/isnd/Data/Account/RegisterViewModel.cs @@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; -namespace isn.Data +namespace isnd.Data { public class RegisterViewModel { diff --git a/src/isnd/Data/ApiKeys/ApiKey.cs b/src/isnd/Data/ApiKeys/ApiKey.cs index 7e3c8bb..517e93a 100644 --- a/src/isnd/Data/ApiKeys/ApiKey.cs +++ b/src/isnd/Data/ApiKeys/ApiKey.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class ApiKey { diff --git a/src/isnd/Data/ApiKeys/ApiKeyViewModel.cs b/src/isnd/Data/ApiKeys/ApiKeyViewModel.cs index 18f4ccf..2a4f5d8 100644 --- a/src/isnd/Data/ApiKeys/ApiKeyViewModel.cs +++ b/src/isnd/Data/ApiKeys/ApiKeyViewModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class ApiKeyViewModel { diff --git a/src/isnd/Data/ApiKeys/CreateModel.cs b/src/isnd/Data/ApiKeys/CreateModel.cs index e5c651f..af6b909 100644 --- a/src/isnd/Data/ApiKeys/CreateModel.cs +++ b/src/isnd/Data/ApiKeys/CreateModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class CreateModel { diff --git a/src/isnd/Data/ApiKeys/DeleteModel.cs b/src/isnd/Data/ApiKeys/DeleteModel.cs index 24551ec..87aaf0e 100644 --- a/src/isnd/Data/ApiKeys/DeleteModel.cs +++ b/src/isnd/Data/ApiKeys/DeleteModel.cs @@ -1,4 +1,4 @@ -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class DeleteModel { diff --git a/src/isnd/Data/ApiKeys/DetailModel.cs b/src/isnd/Data/ApiKeys/DetailModel.cs index 90b4cee..2682dc9 100644 --- a/src/isnd/Data/ApiKeys/DetailModel.cs +++ b/src/isnd/Data/ApiKeys/DetailModel.cs @@ -1,4 +1,4 @@ -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class DetailModel : ApiKeyViewModel { diff --git a/src/isnd/Data/ApiKeys/EditModel.cs b/src/isnd/Data/ApiKeys/EditModel.cs index 0f55d8f..fc6e200 100644 --- a/src/isnd/Data/ApiKeys/EditModel.cs +++ b/src/isnd/Data/ApiKeys/EditModel.cs @@ -1,4 +1,4 @@ -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class EditModel { diff --git a/src/isnd/Data/ApiKeys/IndexModel.cs b/src/isnd/Data/ApiKeys/IndexModel.cs index 01644a1..58e7a85 100644 --- a/src/isnd/Data/ApiKeys/IndexModel.cs +++ b/src/isnd/Data/ApiKeys/IndexModel.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace isn.Data.ApiKeys +namespace isnd.Data.ApiKeys { public class IndexModel { diff --git a/src/isnd/Data/ApplicationDbContext.cs b/src/isnd/Data/ApplicationDbContext.cs index 62a72ba..e52429b 100644 --- a/src/isnd/Data/ApplicationDbContext.cs +++ b/src/isnd/Data/ApplicationDbContext.cs @@ -4,10 +4,10 @@ using System.Text; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -using isn.Data; -using isn.Data.ApiKeys; +using isnd.Data; +using isnd.Data.ApiKeys; -namespace isn.Data +namespace isnd.Data { public class ApplicationDbContext : IdentityDbContext { diff --git a/src/isnd/Data/ApplicationUser.cs b/src/isnd/Data/ApplicationUser.cs index cb277a9..4814bba 100644 --- a/src/isnd/Data/ApplicationUser.cs +++ b/src/isnd/Data/ApplicationUser.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Identity; -namespace isn.Data +namespace isnd.Data { // Add profile data for application users by adding properties to the ApplicationUser class public class ApplicationUser : IdentityUser diff --git a/src/isnd/Data/NewReleaseInfo.cs b/src/isnd/Data/NewReleaseInfo.cs index b68e788..ef69c09 100644 --- a/src/isnd/Data/NewReleaseInfo.cs +++ b/src/isnd/Data/NewReleaseInfo.cs @@ -1,6 +1,6 @@ using System; -namespace isn.Data +namespace isnd.Data { public class NewReleaseInfo { diff --git a/src/isnd/Data/Package.cs b/src/isnd/Data/Package.cs index 1e88155..bd0a733 100644 --- a/src/isnd/Data/Package.cs +++ b/src/isnd/Data/Package.cs @@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; -namespace isn.Data +namespace isnd.Data { public class Package { diff --git a/src/isnd/Data/PackageVersion.cs b/src/isnd/Data/PackageVersion.cs index 7cd6a86..5888694 100644 --- a/src/isnd/Data/PackageVersion.cs +++ b/src/isnd/Data/PackageVersion.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; -namespace isn.Data +namespace isnd.Data { public class PackageVersion { diff --git a/src/isnd/Data/Roles/Administrator.cs b/src/isnd/Data/Roles/Administrator.cs index 9658103..7c5d9e5 100644 --- a/src/isnd/Data/Roles/Administrator.cs +++ b/src/isnd/Data/Roles/Administrator.cs @@ -1,4 +1,4 @@ -namespace isn.Data.Roles +namespace isnd.Data.Roles { public class AdminStartupList { diff --git a/src/isnd/Entities/NugetSettings.cs b/src/isnd/Entities/NugetSettings.cs index 0fe82b1..8072753 100644 --- a/src/isnd/Entities/NugetSettings.cs +++ b/src/isnd/Entities/NugetSettings.cs @@ -1,4 +1,4 @@ -namespace isn.Entities +namespace isnd.Entities { public class IsndSettings { diff --git a/src/isnd/Entities/SmtpSettings.cs b/src/isnd/Entities/SmtpSettings.cs index f700743..5a4a861 100644 --- a/src/isnd/Entities/SmtpSettings.cs +++ b/src/isnd/Entities/SmtpSettings.cs @@ -1,4 +1,4 @@ -namespace isn.Entities +namespace isnd.Entities { public class SmtpSettings { diff --git a/src/isnd/Extensions/Extensions.cs b/src/isnd/Extensions/Extensions.cs index 66da49f..7753d01 100644 --- a/src/isnd/Extensions/Extensions.cs +++ b/src/isnd/Extensions/Extensions.cs @@ -1,7 +1,7 @@ using System; using Microsoft.AspNetCore.Mvc; -namespace isn.Data +namespace isnd.Data { public static class Extensions { diff --git a/src/isnd/Helpers/NuspecCoreReaderHelpers.cs b/src/isnd/Helpers/NuspecCoreReaderHelpers.cs index 8d860c3..573de1f 100644 --- a/src/isnd/Helpers/NuspecCoreReaderHelpers.cs +++ b/src/isnd/Helpers/NuspecCoreReaderHelpers.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Xml.Linq; using NuGet.Packaging.Core; -namespace isn.Helpers +namespace isnd.Helpers { public static class NuspecCoreReaderHelpers { diff --git a/src/isnd/Interfaces/IMailer.cs b/src/isnd/Interfaces/IMailer.cs index 6720d55..9ade79b 100644 --- a/src/isnd/Interfaces/IMailer.cs +++ b/src/isnd/Interfaces/IMailer.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -namespace isn.Interfaces +namespace isnd.Interfaces { public interface IMailer { diff --git a/src/isnd/Migrations/20210424155323_init.Designer.cs b/src/isnd/Migrations/20210424155323_init.Designer.cs index 84a10c2..79c891f 100644 --- a/src/isnd/Migrations/20210424155323_init.Designer.cs +++ b/src/isnd/Migrations/20210424155323_init.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/20210502153508_api-keys.Designer.cs b/src/isnd/Migrations/20210502153508_api-keys.Designer.cs index f7f7681..05c0c44 100644 --- a/src/isnd/Migrations/20210502153508_api-keys.Designer.cs +++ b/src/isnd/Migrations/20210502153508_api-keys.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/20210508012908_ApkiKey.CreationDate.Designer.cs b/src/isnd/Migrations/20210508012908_ApkiKey.CreationDate.Designer.cs index 652110d..36afbd2 100644 --- a/src/isnd/Migrations/20210508012908_ApkiKey.CreationDate.Designer.cs +++ b/src/isnd/Migrations/20210508012908_ApkiKey.CreationDate.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/20210516060430_packages.Designer.cs b/src/isnd/Migrations/20210516060430_packages.Designer.cs index 4200392..a6cb091 100644 --- a/src/isnd/Migrations/20210516060430_packages.Designer.cs +++ b/src/isnd/Migrations/20210516060430_packages.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/20210522194803_packageVersionKey.Designer.cs b/src/isnd/Migrations/20210522194803_packageVersionKey.Designer.cs index ef4c1e6..dc8c00d 100644 --- a/src/isnd/Migrations/20210522194803_packageVersionKey.Designer.cs +++ b/src/isnd/Migrations/20210522194803_packageVersionKey.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/20210621214109_version-types.Designer.cs b/src/isnd/Migrations/20210621214109_version-types.Designer.cs index dee5f4d..169ddcd 100644 --- a/src/isnd/Migrations/20210621214109_version-types.Designer.cs +++ b/src/isnd/Migrations/20210621214109_version-types.Designer.cs @@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs index 37015c4..5fc1ca9 100644 --- a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using isn.Data; +using isnd.Data; namespace isndhost.Migrations { diff --git a/src/isnd/Program.cs b/src/isnd/Program.cs index 52c18d7..9b0ba1d 100644 --- a/src/isnd/Program.cs +++ b/src/isnd/Program.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace isn +namespace isnd { public class Program { diff --git a/src/isnd/Services/EmailSender.cs b/src/isnd/Services/EmailSender.cs index e7fa57d..c5cbe23 100644 --- a/src/isnd/Services/EmailSender.cs +++ b/src/isnd/Services/EmailSender.cs @@ -8,10 +8,10 @@ using MailKit.Net.Smtp; using MimeKit; using System; -using isn.Interfaces; -using isn.Entities; +using isnd.Interfaces; +using isnd.Entities; -namespace isn.Services +namespace isnd.Services { public class EmailSender : IEmailSender, IMailer { diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index 761048b..9b383d5 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; using System.Linq; -using isn.Controllers; -using isn.Data; -using isn.ViewModels; +using isnd.Controllers; +using isnd.Data; using isnd.ViewModels; using Microsoft.EntityFrameworkCore; using NuGet.Versioning; @@ -34,6 +33,7 @@ namespace isnd.Services return new PackageIndexViewModel { + query = query, totalHits = total, data = pkgs }; diff --git a/src/isnd/Services/SearchResult.cs b/src/isnd/Services/SearchResult.cs index 14d8fef..f7b1e4d 100644 --- a/src/isnd/Services/SearchResult.cs +++ b/src/isnd/Services/SearchResult.cs @@ -1,4 +1,4 @@ -using isn.Data; +using isnd.Data; namespace isnd.Services { diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index bcd6725..13a108a 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -6,12 +6,12 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.Hosting; -using isn.Data; -using isn.Interfaces; -using isn.Services; -using isn.Entities; -using isn.Authorization; -using isn.Data.Roles; +using isnd.Data; +using isnd.Interfaces; +using isnd.Services; +using isnd.Entities; +using isnd.Authorization; +using isnd.Data.Roles; using Microsoft.AspNetCore.Authorization; using Unleash; using System.Collections.Generic; @@ -22,7 +22,7 @@ using Microsoft.Extensions.Options; using isnd.Helpers; using isnd.Services; -namespace isn +namespace isnd { public class Startup { @@ -110,7 +110,7 @@ namespace isn { routes.MapRoute( name: "default", - template: "{controller=PackageVersion}/{action=Index}/{PackageId?}"); + template: "{controller=Packages}/{action=Index}/{query?}"); }); } } diff --git a/src/isnd/ViewModels/HomeIndexViewModel.cs b/src/isnd/ViewModels/HomeIndexViewModel.cs index b2c8d70..3dac63c 100644 --- a/src/isnd/ViewModels/HomeIndexViewModel.cs +++ b/src/isnd/ViewModels/HomeIndexViewModel.cs @@ -1,6 +1,6 @@ using Unleash; -namespace isn.ViewModels +namespace isnd.ViewModels { public class HomeIndexViewModel { diff --git a/src/isnd/ViewModels/PackageDetailViewModel.cs b/src/isnd/ViewModels/PackageDetailViewModel.cs new file mode 100644 index 0000000..40d31af --- /dev/null +++ b/src/isnd/ViewModels/PackageDetailViewModel.cs @@ -0,0 +1,15 @@ +using isnd.Data; + +namespace isnd.ViewModels +{ + public class PackageDetailViewModel + { + public PackageVersion latest { get; set; } + + public string pkgid { get; set; } + public int totalHits { get; set; } + public PackageVersion[] data { get; set; } + + + } +} \ No newline at end of file diff --git a/src/isnd/ViewModels/PackageIndexViewModel.cs b/src/isnd/ViewModels/PackageIndexViewModel.cs index 0469f82..7d35697 100644 --- a/src/isnd/ViewModels/PackageIndexViewModel.cs +++ b/src/isnd/ViewModels/PackageIndexViewModel.cs @@ -1,11 +1,12 @@ -using isn.Data; +using isnd.Data; namespace isnd.ViewModels { public class PackageIndexViewModel { + public bool Prerelease { get; set; } public Package[] data {get; set;} - public string Query { get; set; } + public string query { get; set; } public int totalHits { get; internal set; } } } \ No newline at end of file diff --git a/src/isnd/ViewModels/PackageVersionIndexViewModel.cs b/src/isnd/ViewModels/PackageVersionIndexViewModel.cs index 5dad0cd..386a0d5 100644 --- a/src/isnd/ViewModels/PackageVersionIndexViewModel.cs +++ b/src/isnd/ViewModels/PackageVersionIndexViewModel.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using isn.Data; +using isnd.Data; -namespace isn.ViewModels +namespace isnd.ViewModels { public class PackageVersionIndexViewModel { diff --git a/src/isnd/Views/ApiKeys/Create.cshtml b/src/isnd/Views/ApiKeys/Create.cshtml index 4262f28..affb5f9 100644 --- a/src/isnd/Views/ApiKeys/Create.cshtml +++ b/src/isnd/Views/ApiKeys/Create.cshtml @@ -1,5 +1,5 @@ -@model isn.Data.ApiKeys.CreateModel +@model isnd.Data.ApiKeys.CreateModel @{ ViewData["Title"] = "Create"; diff --git a/src/isnd/Views/ApiKeys/Delete.cshtml b/src/isnd/Views/ApiKeys/Delete.cshtml index b861903..5955a1f 100644 --- a/src/isnd/Views/ApiKeys/Delete.cshtml +++ b/src/isnd/Views/ApiKeys/Delete.cshtml @@ -1,5 +1,5 @@ -@model isn.Data.ApiKeys.DeleteModel +@model isnd.Data.ApiKeys.DeleteModel @{ ViewData["Title"] = "Delete"; diff --git a/src/isnd/Views/ApiKeys/Details.cshtml b/src/isnd/Views/ApiKeys/Details.cshtml index 5ed503a..ff41693 100644 --- a/src/isnd/Views/ApiKeys/Details.cshtml +++ b/src/isnd/Views/ApiKeys/Details.cshtml @@ -1,5 +1,5 @@ -@model isn.Data.ApiKeys.DetailModel +@model isnd.Data.ApiKeys.DetailModel @{ ViewData["Title"] = "Details"; diff --git a/src/isnd/Views/ApiKeys/Edit.cshtml b/src/isnd/Views/ApiKeys/Edit.cshtml index 6818a4f..28cb18a 100644 --- a/src/isnd/Views/ApiKeys/Edit.cshtml +++ b/src/isnd/Views/ApiKeys/Edit.cshtml @@ -1,5 +1,5 @@ -@model isn.Data.ApiKeys.EditModel +@model isnd.Data.ApiKeys.EditModel @{ ViewData["Title"] = "Edit"; diff --git a/src/isnd/Views/ApiKeys/Index.cshtml b/src/isnd/Views/ApiKeys/Index.cshtml index ee3e28f..215194a 100644 --- a/src/isnd/Views/ApiKeys/Index.cshtml +++ b/src/isnd/Views/ApiKeys/Index.cshtml @@ -1,5 +1,5 @@ -@model isn.Data.ApiKeys.IndexModel +@model isnd.Data.ApiKeys.IndexModel @{ ViewData["Title"] = "Index"; diff --git a/src/isnd/Views/Home/Index.cshtml b/src/isnd/Views/Home/Index.cshtml index 63e52f6..090f984 100644 --- a/src/isnd/Views/Home/Index.cshtml +++ b/src/isnd/Views/Home/Index.cshtml @@ -8,7 +8,7 @@

Welcome

- Welcome to isn + Welcome to isnd

@Model.PkgCount identifiant(s) de paquet dans le SI diff --git a/src/isnd/Views/PackageVersion/Delete.cshtml b/src/isnd/Views/PackageVersion/Delete.cshtml index f463933..d1b47d2 100644 --- a/src/isnd/Views/PackageVersion/Delete.cshtml +++ b/src/isnd/Views/PackageVersion/Delete.cshtml @@ -1,4 +1,4 @@ -@model isn.Data.PackageVersion +@model isnd.Data.PackageVersion @{ ViewData["Title"] = "Delete"; diff --git a/src/isnd/Views/PackageVersion/Details.cshtml b/src/isnd/Views/PackageVersion/Details.cshtml index f0dfb00..93f5d3c 100644 --- a/src/isnd/Views/PackageVersion/Details.cshtml +++ b/src/isnd/Views/PackageVersion/Details.cshtml @@ -1,4 +1,4 @@ -@model isn.Data.PackageVersion +@model isnd.Data.PackageVersion @{ ViewData["Title"] = "Details"; diff --git a/src/isnd/Views/Packages/Details.cshtml b/src/isnd/Views/Packages/Details.cshtml new file mode 100644 index 0000000..0b7feee --- /dev/null +++ b/src/isnd/Views/Packages/Details.cshtml @@ -0,0 +1,37 @@ +@model PackageDetailViewModel + +@{ + ViewData["Title"] = "Details"; +} + +

Details

+ +
+

PackageVersion

+
+
+
+ @Html.DisplayNameFor(model => model.latest.IsPrerelease) +
+
+ @Html.DisplayFor(model => model.latest.IsPrerelease) +
+
+ @Html.DisplayNameFor(model => model.latest.PackageId) +
+
+ @Html.DisplayFor(model => model.latest.PackageId) +
+
+ @Html.DisplayNameFor(model => model.latest.FullString) +
+
+ @Html.DisplayFor(model => model.latest.FullString) + nuspec +
+
+
+
+ @Html.ActionLink("Edit", "Edit", new { pkgid = Model.pkgid, version = Model.latest.FullString }) | + Back to List +
diff --git a/src/isnd/Views/Packages/Index.cshtml b/src/isnd/Views/Packages/Index.cshtml new file mode 100644 index 0000000..833f974 --- /dev/null +++ b/src/isnd/Views/Packages/Index.cshtml @@ -0,0 +1,53 @@ +@model PackageIndexViewModel + +@{ + ViewData["Title"] = "Index"; +} + +

Index

+ +

+

+
+ +
+ + + +
+
+ +
+
+

+ + + + + + + + + + +@foreach (var item in Model.data) { + + + + + +} + +
+ @Html.DisplayNameFor(model => model.data[0].Id) + + @Html.DisplayNameFor(model => model.data[0].Description) +
+ @Html.DisplayFor(modelItem => item.Id) + + + @Html.DisplayFor(modelItem => item.Description) + + @Html.ActionLink("Details", "Details", new { pkgid = item.Id }) | + @Html.ActionLink("Delete", "Delete", new { pkgid = item.Id }) +
diff --git a/src/isnd/Views/_ViewImports.cshtml b/src/isnd/Views/_ViewImports.cshtml index 064a877..f0f32a9 100644 --- a/src/isnd/Views/_ViewImports.cshtml +++ b/src/isnd/Views/_ViewImports.cshtml @@ -1,3 +1,3 @@ -@using isn.Data -@using isn.ViewModels +@using isnd.Data +@using isnd.ViewModels @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs index 99730f2..fc00229 100644 --- a/test/isnd.tests/UnitTestWebHost.cs +++ b/test/isnd.tests/UnitTestWebHost.cs @@ -1,9 +1,8 @@ using System; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore; -using isn; using Xunit; -using isn.Data; +using isnd.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging;