Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
Upgrade to .net 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anduin2017 committed Dec 8, 2020
1 parent c1bbae4 commit aa04071
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/Aiursoft.Blog.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Description>Anduin's personal blog.</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aiursoft.Pylon" Version="0.20.1" />
<PackageReference Include="Aiursoft.Identity" Version="5.0.1" />
</ItemGroup>

</Project>
20 changes: 10 additions & 10 deletions src/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Aiursoft.Blog.Models;
using Aiursoft.Pylon.Attributes;
using Aiursoft.Pylon.Services;
using Aiursoft.Handler.Attributes;
using Aiursoft.Probe.SDK.Services;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
Expand All @@ -16,13 +16,13 @@ namespace Aiursoft.Blog.Controllers
public class ApiController : Controller
{
private readonly UserManager<BlogUser> _userManager;
private readonly ServiceLocation _serviceLocation;
private readonly ProbeLocator _probeLocator;
public ApiController(
UserManager<BlogUser> userManager,
ServiceLocation serviceLocation)
ProbeLocator probeLocator)
{
_userManager = userManager;
_serviceLocation = serviceLocation;
_probeLocator = probeLocator;
}

[Route("/manifest.json")]
Expand All @@ -41,31 +41,31 @@ public async Task<IActionResult> Manifest()
{
new ManifestIcon
{
Src = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + "?w=48&h=48",
Src = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + "?w=48&square=true",
Sizes = "48x48",
Type = "image/png"
},
new ManifestIcon
{
Src = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=72&h=72",
Src = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=72&square=true",
Sizes = "72x72",
Type = "image/png"
},
new ManifestIcon
{
Src = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=144&h=144",
Src = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=144&square=true",
Sizes = "144x144",
Type = "image/png"
},
new ManifestIcon
{
Src = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=240&h=240",
Src = _probeLocator.GetProbeOpenAddress( owner.IconFilePath) + ".png?w=240&square=true",
Sizes = "240x240",
Type = "image/png"
},
new ManifestIcon
{
Src = StorageService.GetProbeDownloadAddress(_serviceLocation, owner.IconFilePath) + ".png?w=512&h=512",
Src = _probeLocator.GetProbeOpenAddress(owner.IconFilePath) + ".png?w=512&square=true",
Sizes = "512x512",
Type = "image/png"
}
Expand Down
10 changes: 6 additions & 4 deletions src/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using Aiursoft.Blog.Models;
using Aiursoft.Pylon;
using Aiursoft.Pylon.Attributes;
using Aiursoft.Pylon.Models.ForApps.AddressModels;
using Aiursoft.Pylon.Services;
using Aiursoft.Gateway.SDK.Models.ForApps.AddressModels;
using Aiursoft.Handler.Attributes;
using Aiursoft.Identity.Attributes;
using Aiursoft.Identity.Services;
using Aiursoft.WebTools;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;

namespace Aiursoft.Blog.Controllers
{
[LimitPerMin]
public class AuthController : Controller
{
private readonly AuthService<BlogUser> _authService;
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Aiursoft.Blog.Models;
using Aiursoft.Blog.Models.HomeViewModels;
using Aiursoft.Pylon;
using Aiursoft.Pylon.Attributes;
using Aiursoft.Pylon.Models;
using Aiursoft.Pylon.Services;
using Aiursoft.Identity;
using Aiursoft.Identity.Attributes;
using Aiursoft.SDK.Services;
using Aiursoft.XelNaga.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/BlogUser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aiursoft.Pylon.Models;
using Aiursoft.Gateway.SDK.Models;

namespace Aiursoft.Blog.Models
{
Expand Down
12 changes: 5 additions & 7 deletions src/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
using Aiursoft.Blog.Data;
using Aiursoft.Pylon;
using Aiursoft.SDK;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using static Aiursoft.WebTools.Extends;

namespace Aiursoft.Blog
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args)
.Build()
.MigrateDbContext<BlogDbContext>()
.Run();
App<Startup>(args).Update<BlogDbContext>().Run();
}

// For EF
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
return BareApp<Startup>(args);
}
}
}
17 changes: 11 additions & 6 deletions src/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
using Aiursoft.Blog.Data;
using Aiursoft.Blog.Models;
using Aiursoft.Pylon;
using Aiursoft.Identity;
using Aiursoft.SDK;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Aiursoft.Identity;

namespace Aiursoft.Blog
{
public class Startup
{
private readonly IConfiguration _configuration;
private readonly IConfiguration Configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
Configuration = configuration;
}

public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<BlogDbContext>(options =>
options.UseSqlServer(_configuration.GetConnectionString("DatabaseConnection")));
services.AddDbContextWithCache<BlogDbContext>(Configuration.GetConnectionString("DatabaseConnection"));

services.AddIdentity<BlogUser, IdentityRole>()
.AddEntityFrameworkStores<BlogDbContext>()
.AddDefaultTokenProviders();
services.AddAiurMvc();
services.AddAiurDependencies<BlogUser>("Blog");
services.AddAiursoftIdentity<BlogUser>(
archonEndpoint: Configuration.GetConnectionString("ArchonConnection"),
observerEndpoint: Configuration.GetConnectionString("ObserverConnection"),
probeEndpoint: Configuration.GetConnectionString("ProbeConnection"),
gateEndpoint: Configuration.GetConnectionString("GatewayConnection"));
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<div class="card card-profile mb-4">
<div class="card-header" style="background-image: url(/img/iceland.jpg);"></div>
<div class="card-body text-center">
<a href="@StorageService.GetProbeDownloadAddress(ServiceLocation, Model.Owner.IconFilePath)?w=300&h=300" target="_blank">
<img src="@StorageService.GetProbeDownloadAddress(ServiceLocation, Model.Owner.IconFilePath)?w=300&h=300" style="width:94px; height:94px" class="card-profile-img" />
<a href="@ProbeLocator.GetProbeOpenAddress(Model.Owner.IconFilePath)?w=300&h=300" target="_blank">
<img src="@ProbeLocator.GetProbeOpenAddress(Model.Owner.IconFilePath)?w=300&h=300" style="width:94px; height:94px" class="card-profile-img" />
</a>

<h6 class="card-title">
Expand Down
8 changes: 5 additions & 3 deletions src/Views/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@using Microsoft.AspNetCore.Identity
@using Aiursoft.Blog
@using Aiursoft.Blog.Models
@using Aiursoft.Pylon
@using Aiursoft.Pylon.Services
@using Aiursoft.Pylon.Models
@using Aiursoft.Identity.Services
@using Aiursoft.SDK
@using Aiursoft.SDK.Services
@using Aiursoft.Probe.SDK.Services
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Configuration;

Expand All @@ -12,6 +13,7 @@
@inject IConfiguration Configuration
@inject ServiceLocation ServiceLocation
@inject IViewLocalizer Localizer
@inject ProbeLocator ProbeLocator
@inject UserImageGenerator<BlogUser> UserImageGenerator

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Expand Down
6 changes: 5 additions & 1 deletion src/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"ConnectionStrings": {
"DatabaseConnection": "Server=(localdb)\\mssqllocaldb;Database=Blog;Trusted_Connection=True;MultipleActiveResultSets=true"
"DatabaseConnection": "Server=(localdb)\\mssqllocaldb;Database=Blog;Trusted_Connection=True;MultipleActiveResultSets=true",
"ArchonConnection": "https://archon.aiursoft.com",
"ObserverConnection": "https://observer.aiursoft.com",
"ProbeConnection": "https://probe.aiursoft.com",
"GatewayConnection": "https://gateway.aiursoft.com"
},
"BlogAppId": "",
"BlogAppSecret": "",
Expand Down

0 comments on commit aa04071

Please sign in to comment.