Skip to content

Commit

Permalink
Merge pull request #22 from ThatChocolateGuy/upgrade-to-dotnet-8
Browse files Browse the repository at this point in the history
upgrade .NET Core 2.1 to .NET 8
  • Loading branch information
ThatChocolateGuy authored May 26, 2024
2 parents ccc1e99 + 5bbc4d6 commit 5420d94
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 107 deletions.
5 changes: 2 additions & 3 deletions Controllers/CertificatesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ from customer in await _context.Customer.ToListAsync()
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(
[Bind("Price,CertQty,CustomerName,CustomerEmail,CustomerPhone,StaffName,ChannelName,PromoAmt"
)] CertificateCreateViewModel certificateCreateViewModel)
[Bind("Price,CertQty,CustomerName,CustomerEmail,CustomerPhone,StaffName,ChannelName,PromoAmt")] CertificateCreateViewModel certificateCreateViewModel)
{
if (ModelState.IsValid)
{
try
{
int result = _context.Database.ExecuteSqlCommand(@"
int result = _context.Database.ExecuteSqlRaw(@"
EXEC stpAssignCertificate
@customer_name = @customerName
,@customer_email = @customerEmail
Expand Down
2 changes: 1 addition & 1 deletion Controllers/StaffController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private async Task createStaffLink(Staff staff_userInput, Staff _newStaff)
/// <param name="staffCreatedParam"></param>
private void ExecStpAssignStaff(Staff staff_userInput, string hashed_pw, SqlParameter messageParam, SqlParameter staffCreatedParam)
{
_ = _context.Database.ExecuteSqlCommand(
_ = _context.Database.ExecuteSqlRaw(
@"EXEC [dbo].[stpAssignStaff]
@staff_name = @name
,@staff_email = @email
Expand Down
28 changes: 15 additions & 13 deletions Controllers/TotalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from link in await _context.CertificateLink.ToListAsync().ConfigureAwait(false)
};

ViewBag.Certs = certificateDetails.Select(m => m.Certificate).Distinct().Count();
ViewBag.Channel = certificateDetails.Select(m => m.Channel).Distinct().Count();
ViewBag.Channel = certificateDetails.Select(m => m.Channel).DefaultIfEmpty().Distinct().Count();
ViewBag.Customer = certificateDetails.Select(m => m.Customer).Distinct().Count();
ViewBag.Promo = certificateDetails.Select(m => m.Promotion).Distinct().Count();

Expand All @@ -52,28 +52,30 @@ from link in await _context.CertificateLink.ToListAsync().ConfigureAwait(false)
.Select(m => m.Certificate).Where(c => c.DateRedeemed.HasValue).Count();

// Certificates by Promotion data
IEnumerable<Promotion> promos = certificateDetails.Select(m => m.Promotion).Distinct();
IEnumerable<int> certsByPromoLabels = certificateDetails.Select(m => m.Promotion.Discount).Distinct();
List<int> certsByPromoArray = new List<int>();
certsByPromoArray.AddRange(
promos.Select(
IEnumerable<Promotion> promos = certificateDetails.Select(m => m.Promotion).DefaultIfEmpty().Distinct();
IEnumerable<int> certsByPromoLabels = certificateDetails.Select(m => m.Promotion.Discount).DefaultIfEmpty().Distinct();
List<int> certsByPromoArray =
[
.. promos.Select(
promo => certificateDetails.Select(
m => m.Certificate).Where(
c => c.CertificateLink.Promotion.Discount == promo.Discount).Count()));
c => c.CertificateLink.Promotion?.Discount == promo?.Discount).DefaultIfEmpty().Count()),
];
ViewBag.CertsByPromoArray = string.Join(",", certsByPromoArray);
ViewBag.CertsByPromoLabels = string.Concat(
certsByPromoLabels.Select(i => string.Format(
null, i != 0 ? "`${0} discount`," : "`No Promo`,", i)));

// Certificates by Channel data
IEnumerable<Channel> channels = certificateDetails.Select(m => m.Channel).Distinct();
IEnumerable<string> certsByChannelLabels = certificateDetails.Select(m => m.Channel.ChannelName).Distinct();
List<int> certsByChannelArray = new List<int>();
certsByChannelArray.AddRange(
channels.Select(
IEnumerable<Channel> channels = certificateDetails.Select(m => m.Channel).DefaultIfEmpty().Distinct();
IEnumerable<string> certsByChannelLabels = certificateDetails.Select(m => m.Channel?.ChannelName).DefaultIfEmpty().Distinct();
List<int> certsByChannelArray =
[
.. channels.Select(
channel => certificateDetails.Select(
m => m.Certificate).Where(
c => c.CertificateLink.Channel.ChannelName == channel.ChannelName).Count()));
c => c.CertificateLink.Channel?.ChannelName == channel?.ChannelName).DefaultIfEmpty().Count()),
];
ViewBag.CertsByChannelArray = string.Join(",", certsByChannelArray);
ViewBag.CertsByChannelLabels = string.Concat(
certsByChannelLabels.Select(i => string.Format(null, "`{0}`,", i)));
Expand Down
Binary file modified Data/certitrack.ldf
Binary file not shown.
Binary file modified Data/certitrack.mdf
Binary file not shown.
24 changes: 13 additions & 11 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Hosting;
using System;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -71,9 +71,7 @@ public static void ConfigureServices(IServiceCollection services)
options.FormFieldName = "CSRF-TOKEN-CERTITRACK-FORM";
});

services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddSessionStateTempDataProvider();
services.AddRazorPages();

services.AddSingleton<ITempDataProvider, CookieTempDataProvider>();
services.AddSession();
Expand All @@ -82,7 +80,7 @@ public static void ConfigureServices(IServiceCollection services)
services.AddDistributedMemoryCache();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
if(env == null)
{
Expand All @@ -93,8 +91,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
{
SetConnectionStringWithContentRootPath(env);

loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
//loggerFactory.AddDebug();

app.UseDeveloperExceptionPage();
}
Expand All @@ -113,15 +111,19 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app.UseSession();
app.UseAuthentication();

app.UseMvc(routes =>
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
routes.MapRoute(
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: "default",
template: "{controller=Account}/{action=Login}/{id?}");
pattern: "{controller=Account}/{action=Login}/{id?}");
});
}

private void SetConnectionStringWithContentRootPath(IHostingEnvironment env)
private void SetConnectionStringWithContentRootPath(IWebHostEnvironment env)
{
string ContentRootPath = env.ContentRootPath;

Expand Down
2 changes: 1 addition & 1 deletion Views/Customers/Print.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- Bootstrap 3 -->
<link rel="stylesheet" href="~/vendor/bootstrap/dist/css/bootstrap.min.css">
<!-- Custom styling -->
<link rel="stylesheet" href="~/css/custom.css?v=1">
<link rel="stylesheet" href="~/css/custom.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<!-- Main content -->
Expand Down
2 changes: 1 addition & 1 deletion Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<link rel="stylesheet" href="~/dist/css/AdminLTE.css">
<link rel="stylesheet" href="~/dist/css/skins/skin-green.min.css">
<!-- Custom styling -->
<link rel="stylesheet" href="~/css/custom.css?v=2">
<link rel="stylesheet" href="~/css/custom.css">
<!-- Google Font -->
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
Expand Down
109 changes: 34 additions & 75 deletions certitrack-certificate-manager.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Certitrack</RootNamespace>
<UserSecretsId>079515d2-1b25-43ae-be6f-6d7b242711f9</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<ApplicationIcon />
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<Win32Resource />
</PropertyGroup>

<ItemGroup>
<Compile Remove="wwwroot\bower_components %28old%29\**" />
<Compile Remove="wwwroot\bower_components - Copy\**" />
Expand All @@ -25,109 +24,69 @@
<None Remove="wwwroot\bower_components - Copy\**" />
<None Remove="wwwroot\bower_components\**" />
</ItemGroup>

<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Data\certitrack.mdf" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="EntityFramework.SqlServerCompact" Version="6.2.0" />
<PackageReference Include="EntityFramework.SqlServerCompact" Version="6.4.4" />
<PackageReference Include="jsreport.AspNetCore" Version="2.0.1" />
<PackageReference Include="jsreport.Binary" Version="2.6.1" />
<PackageReference Include="jsreport.Binary.Linux" Version="2.6.1" />
<PackageReference Include="jsreport.Local" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.22" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Localization.Routing" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ApiExplorer" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.8.0" />
<PackageReference Include="jsreport.Local" Version="3.0.0" />
<!--<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.3.0" />-->
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Razor" Version="2.1.1" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.8" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="2.1.1" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.1.1" />
<!--<PackageReference Include="Microsoft.Net.Http.Headers" Version="3.0.0" />-->
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="8.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<!--<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.6.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>-->
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
</ItemGroup>

<!--<ItemGroup>
<TypeScriptCompile Include="wwwroot\bower_components\moment\moment.d.ts" />
</ItemGroup>-->

<ItemGroup>
<Folder Include="jsreport\" />
</ItemGroup>

<ProjectExtensions>
<VisualStudio>
<UserProperties appsettings_1json__JSONSchema="http://json.schemastore.org/appsettings" />
</VisualStudio>
</ProjectExtensions>

</Project>
</Project>
4 changes: 2 additions & 2 deletions certitrack-certificate-manager.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "certitrack-certificate-manager", "certitrack-certificate-manager.csproj", "{33032F99-7FAA-40ED-B127-E6D555C71885}"
EndProject
Expand Down

0 comments on commit 5420d94

Please sign in to comment.