mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Migrate to .NET Core 3.1.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>Marechai.Database</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.4" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
public class CompanyLogosController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public CompanyLogosController(MarechaiContext context, IHostingEnvironment env)
|
||||
public CompanyLogosController(MarechaiContext context, IWebHostEnvironment env)
|
||||
{
|
||||
_context = context;
|
||||
hostingEnvironment = env;
|
||||
@@ -144,7 +144,8 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
})
|
||||
{
|
||||
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format)))
|
||||
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format));
|
||||
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos",
|
||||
format));
|
||||
|
||||
SKEncodedImageFormat skFormat;
|
||||
|
||||
@@ -280,8 +281,7 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
float scale = canvasMin / svgMax;
|
||||
var matrix = SKMatrix.MakeScale(scale, scale);
|
||||
|
||||
var bitmap =
|
||||
new SKBitmap((int)(svgSize.Width * scale), (int)(svgSize.Height * scale));
|
||||
var bitmap = new SKBitmap((int)(svgSize.Width * scale), (int)(svgSize.Height * scale));
|
||||
|
||||
var canvas = new SKCanvas(bitmap);
|
||||
canvas.DrawPicture(svg.Picture, ref matrix);
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
public class MachinePhotosController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
readonly UserManager<ApplicationUser> userManager;
|
||||
|
||||
public MachinePhotosController(MarechaiContext context, IHostingEnvironment hostingEnvironment,
|
||||
public MachinePhotosController(MarechaiContext context, IWebHostEnvironment hostingEnvironment,
|
||||
UserManager<ApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
@@ -56,29 +56,19 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
MachinePhotoDetailsViewModel machinePhoto =
|
||||
await _context.MachinePhotos.Select(m => new MachinePhotoDetailsViewModel
|
||||
{
|
||||
Id = m.Id, CameraManufacturer = m.CameraManufacturer,
|
||||
CameraModel = m.CameraModel,
|
||||
ColorSpace = m.ColorSpace, Comments = m.Comments,
|
||||
Contrast = m.Contrast,
|
||||
CreationDate = m.CreationDate, DigitalZoomRatio = m.DigitalZoomRatio,
|
||||
ExifVersion = m.ExifVersion,
|
||||
Exposure = m.Exposure, ExposureProgram = m.ExposureProgram,
|
||||
Flash = m.Flash, Focal = m.Focal,
|
||||
FocalLength = m.FocalLength, FocalLengthEquivalent = m.FocalLengthEquivalent,
|
||||
HorizontalResolution = m.HorizontalResolution, IsoRating = m.IsoRating,
|
||||
Lens = m.Lens,
|
||||
LightSource = m.LightSource, MeteringMode = m.MeteringMode,
|
||||
ResolutionUnit = m.ResolutionUnit,
|
||||
Orientation = m.Orientation, Saturation = m.Saturation,
|
||||
SceneCaptureType = m.SceneCaptureType,
|
||||
SensingMethod = m.SensingMethod, Sharpness = m.Sharpness,
|
||||
SoftwareUsed = m.SoftwareUsed,
|
||||
Id = m.Id, CameraManufacturer = m.CameraManufacturer, CameraModel = m.CameraModel,
|
||||
ColorSpace = m.ColorSpace, Comments = m.Comments, Contrast = m.Contrast,
|
||||
CreationDate = m.CreationDate, DigitalZoomRatio = m.DigitalZoomRatio, ExifVersion = m.ExifVersion,
|
||||
Exposure = m.Exposure, ExposureProgram = m.ExposureProgram, Flash = m.Flash, Focal = m.Focal,
|
||||
FocalLength = m.FocalLength, FocalLengthEquivalent = m.FocalLengthEquivalent,
|
||||
HorizontalResolution = m.HorizontalResolution, IsoRating = m.IsoRating, Lens = m.Lens,
|
||||
LightSource = m.LightSource, MeteringMode = m.MeteringMode, ResolutionUnit = m.ResolutionUnit,
|
||||
Orientation = m.Orientation, Saturation = m.Saturation, SceneCaptureType = m.SceneCaptureType,
|
||||
SensingMethod = m.SensingMethod, Sharpness = m.Sharpness, SoftwareUsed = m.SoftwareUsed,
|
||||
SubjectDistanceRange = m.SubjectDistanceRange, UploadDate = m.UploadDate,
|
||||
VerticalResolution = m.VerticalResolution, WhiteBalance = m.WhiteBalance,
|
||||
License = m.License.Name,
|
||||
UploadUser = m.User.UserName,
|
||||
Machine = $"{m.Machine.Company.Name} {m.Machine.Name}",
|
||||
MachineId = m.Machine.Id, Source = m.Source
|
||||
VerticalResolution = m.VerticalResolution, WhiteBalance = m.WhiteBalance, License = m.License.Name,
|
||||
UploadUser = m.User.UserName, Machine = $"{m.Machine.Company.Name} {m.Machine.Name}",
|
||||
MachineId = m.Machine.Id, Source = m.Source
|
||||
}).FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(machinePhoto == null)
|
||||
@@ -233,10 +223,9 @@ namespace Marechai.Areas.Admin.Controllers
|
||||
await _context.MachinePhotos.Include(m => m.Machine).Include(m => m.Machine.Company).
|
||||
Include(m => m.User).Select(p => new MachinePhotoViewModel
|
||||
{
|
||||
Id = p.Id, Author = p.Author,
|
||||
License = p.License.Name,
|
||||
Id = p.Id, Author = p.Author, License = p.License.Name,
|
||||
Machine = $"{p.Machine.Company.Name} {p.Machine.Name}", UploadDate = p.UploadDate,
|
||||
UploadUser = p.User.UserName, LicenseId = p.License.Id
|
||||
UploadUser = p.User.UserName, LicenseId = p.License.Id
|
||||
}).OrderBy(p => p.Machine).ThenBy(p => p.UploadUser).ThenBy(p => p.UploadDate).
|
||||
FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Marechai.Areas.Admin.Models
|
||||
public string Company;
|
||||
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
|
||||
public DateTime? Introduced;
|
||||
[DisplayName("Model code")]
|
||||
public string ModelCode;
|
||||
public string Name;
|
||||
[DisplayName("Model code")]
|
||||
public string ModelCode { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Marechai.Areas.Admin.Models
|
||||
public class GpusByMachineViewModel : BaseViewModel<long>
|
||||
{
|
||||
[DisplayName("GPU")]
|
||||
public string Gpu;
|
||||
public string Machine;
|
||||
public string Gpu { get; set; }
|
||||
public string Machine { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,9 @@ namespace Marechai.Controllers
|
||||
public class CompanyController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public CompanyController(IHostingEnvironment env, MarechaiContext context)
|
||||
public CompanyController(IWebHostEnvironment env, MarechaiContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
@@ -70,9 +70,8 @@ namespace Marechai.Controllers
|
||||
return View(_context.Companies.Include(c => c.Logos).Where(c => c.Name.StartsWith(id)).OrderBy(c => c.Name).
|
||||
Select(c => new CompanyViewModel
|
||||
{
|
||||
Id = c.Id,
|
||||
LastLogo = c.Logos.OrderByDescending(l => l.Year).FirstOrDefault().Guid,
|
||||
Name = c.Name
|
||||
Id = c.Id, LastLogo = c.Logos.OrderByDescending(l => l.Year).FirstOrDefault().Guid,
|
||||
Name = c.Name
|
||||
}).ToList());
|
||||
}
|
||||
|
||||
@@ -101,9 +100,8 @@ namespace Marechai.Controllers
|
||||
return View(_context.Companies.Include(c => c.Logos).Where(c => c.CountryId == id).OrderBy(c => c.Name).
|
||||
Select(c => new CompanyViewModel
|
||||
{
|
||||
Id = c.Id,
|
||||
LastLogo = c.Logos.OrderByDescending(l => l.Year).FirstOrDefault().Guid,
|
||||
Name = c.Name
|
||||
Id = c.Id, LastLogo = c.Logos.OrderByDescending(l => l.Year).FirstOrDefault().Guid,
|
||||
Name = c.Name
|
||||
}).ToList());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace Marechai.Controllers
|
||||
public class ComputerController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public ComputerController(IHostingEnvironment env, MarechaiContext context)
|
||||
public ComputerController(IWebHostEnvironment env, MarechaiContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
@@ -52,13 +52,11 @@ namespace Marechai.Controllers
|
||||
ViewBag.ItemCount = _context.Machines.Count(m => m.Type == MachineType.Computer);
|
||||
|
||||
ViewBag.MinYear = _context.
|
||||
Machines.Where(t => t.Type == MachineType.Computer &&
|
||||
t.Introduced.HasValue &&
|
||||
Machines.Where(t => t.Type == MachineType.Computer && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year > 1000).Min(t => t.Introduced.Value.Year);
|
||||
|
||||
ViewBag.MaxYear = _context.
|
||||
Machines.Where(t => t.Type == MachineType.Computer &&
|
||||
t.Introduced.HasValue &&
|
||||
Machines.Where(t => t.Type == MachineType.Computer && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year > 1000).Max(t => t.Introduced.Value.Year);
|
||||
|
||||
return View();
|
||||
@@ -95,8 +93,7 @@ namespace Marechai.Controllers
|
||||
{
|
||||
ViewBag.Year = id;
|
||||
|
||||
return View(_context.Machines.Where(t => t.Type == MachineType.Computer &&
|
||||
t.Introduced.HasValue &&
|
||||
return View(_context.Machines.Where(t => t.Type == MachineType.Computer && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year == id).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace Marechai.Controllers
|
||||
public class ConsoleController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public ConsoleController(IHostingEnvironment env, MarechaiContext context)
|
||||
public ConsoleController(IWebHostEnvironment env, MarechaiContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
@@ -52,13 +52,11 @@ namespace Marechai.Controllers
|
||||
ViewBag.ItemCount = _context.Machines.Count(m => m.Type == MachineType.Console);
|
||||
|
||||
ViewBag.MinYear = _context.
|
||||
Machines.Where(t => t.Type == MachineType.Console &&
|
||||
t.Introduced.HasValue &&
|
||||
Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year > 1000).Min(t => t.Introduced.Value.Year);
|
||||
|
||||
ViewBag.MaxYear = _context.
|
||||
Machines.Where(t => t.Type == MachineType.Console &&
|
||||
t.Introduced.HasValue &&
|
||||
Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year > 1000).Max(t => t.Introduced.Value.Year);
|
||||
|
||||
return View();
|
||||
@@ -95,8 +93,7 @@ namespace Marechai.Controllers
|
||||
{
|
||||
ViewBag.Year = id;
|
||||
|
||||
return View(_context.Machines.Where(t => t.Type == MachineType.Console &&
|
||||
t.Introduced.HasValue &&
|
||||
return View(_context.Machines.Where(t => t.Type == MachineType.Console && t.Introduced.HasValue &&
|
||||
t.Introduced.Value.Year == id).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace Marechai.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public HomeController(IHostingEnvironment env, MarechaiContext context)
|
||||
public HomeController(IWebHostEnvironment env, MarechaiContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
@@ -56,7 +56,7 @@ namespace Marechai.Controllers
|
||||
|
||||
List<NewsModel> news = new List<NewsModel>();
|
||||
|
||||
foreach(News @new in _context.News.OrderByDescending(t => t.Date).Take(10))
|
||||
foreach(News @new in _context.News.OrderByDescending(t => t.Date).Take(10).ToList())
|
||||
{
|
||||
Machine machine = _context.Machines.Find(@new.AddedId);
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace Marechai.Controllers
|
||||
public class MachineController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly IWebHostEnvironment hostingEnvironment;
|
||||
|
||||
public MachineController(IHostingEnvironment env, MarechaiContext context)
|
||||
public MachineController(IWebHostEnvironment env, MarechaiContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.895</Version>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.905</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
@@ -18,8 +18,10 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.68.0.2" />
|
||||
<PackageReference Include="Markdig" Version="0.17.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
|
||||
<PackageReference Include="MSBump" Version="2.3.2" PrivateAssets="All" />
|
||||
<PackageReference Include="MySql.Data" Version="8.0.16" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0006" />
|
||||
|
||||
@@ -35,6 +35,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Marechai
|
||||
{
|
||||
@@ -54,30 +55,34 @@ namespace Marechai
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
|
||||
services.AddControllersWithViews();
|
||||
services.AddRazorPages();
|
||||
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http: //go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
|
||||
services.AddDbContext<MarechaiContext>(options => options.
|
||||
UseLazyLoadingProxies().
|
||||
UseMySql("server=localhost;port=3306;user=marechai;password=marechaipass;database=marechai;TreatTinyAsBoolean=false"));
|
||||
|
||||
services.AddMvc();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if(env.IsDevelopment())
|
||||
app.UseDeveloperExceptionPage();
|
||||
else
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseAuthentication();
|
||||
app.UseCookiePolicy();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
routes.MapRoute("areas", "{area:exists}/{controller=Home}/{action=Index}/{id?}").
|
||||
MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
||||
endpoints.MapControllerRoute("areas", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
||||
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user