Skip to content

Commit f4327fd

Browse files
committed
NSwag generálás, DTO Sharedből
csak fordul
1 parent 940075f commit f4327fd

File tree

22 files changed

+1135
-1696
lines changed

22 files changed

+1135
-1696
lines changed

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/Ahk.GradeManagement.Api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.11.0" />
2727
<PackageReference Include="Microsoft.Identity.Web" Version="2.16.0" />
2828
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.16.0" />
29-
<PackageReference Include="NSwag.AspNetCore" Version="14.0.7" />
29+
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
3030
</ItemGroup>
3131

3232
<ItemGroup>

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/Authorization/UserClaimsTransformation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
1313
{
1414
if (principal.Identity is ClaimsIdentity identity && identity.IsAuthenticated)
1515
{
16-
var userEmail = identity.FindFirst(ClaimTypes.Email)?.Value ?? identity.FindFirst("email")?.Value;
16+
var userEmail = principal.GetCurrentUserEmail();
17+
1718
var user = await userService.GetOrCreateUserByEmailAsync(userEmail);
1819
var subjectRoles = await subjectTeacherService.GetAllSubjectsWithRolesForTeacherAsync(user.Id);
1920

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static void Main(string[] args)
4545
builder.Services.AddControllersWithViews();
4646
builder.Services.AddOpenApiDocument(config =>
4747
{
48+
config.DocumentName = "AHK2.OpenAPI";
4849
config.Title = "AHK Grade Management API";
4950
});
5051
builder.Services.AddRazorPages();

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/Properties/launchSettings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
"https": {
2626
"commandName": "Project",
2727
"dotnetRunMessages": true,
28-
"launchBrowser": false,
28+
"launchBrowser": true,
2929
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
30-
"applicationUrl": "https://10.0.0.10:7136;http://10.0.0.10:5180",
30+
"applicationUrl": "https://localhost:7111;http://localhost:5268",
3131
"environmentVariables": {
3232
"ASPNETCORE_ENVIRONMENT": "Development",
3333
"MONITOR_URL": "https://monitor.mm-home.eu/api/github-webhook",
3434
"KEY_VAULT_URI": "https://ahkgithubmonitorsecrets.vault.azure.net/",
35-
"APP_URL": "https://app.mm-home.eu/"
35+
"APP_URL": "https://localhost:7111/"
3636
}
3737
},
3838
"IIS Express": {

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/appsettings.Development.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"ConnectionStrings": {
3+
"DbConnection": "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=GradeManagement.Database;Integrated Security=True"
4+
},
25
"Logging": {
36
"LogLevel": {
47
"Default": "Information",

src/Ahk.GradeManagement/Ahk.GradeManagement.Api/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"AllowedHosts": "*",
1212
"AzureAd": {
1313
"Instance": "https://login.microsoftonline.com/",
14-
"ClientId": "01834b53-87a0-4236-85d3-a999ecec0115",
14+
"ClientId": "0ff49368-7e23-4e6a-9c57-973a6cac8bbd",
1515
"Domain": "m365.bme.hu",
1616
"TenantId": "6a3548ab-7570-4271-91a8-58da00697029"
1717
}

src/Ahk.GradeManagement/Ahk.GradeManagement.Bll/Services/AuthorizationHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ namespace Ahk.GradeManagement.Bll.Services;
66

77
public static class AuthorizationHelper
88
{
9-
public static string GetCurrentUserEmail(ClaimsPrincipal user)
9+
public static string GetCurrentUserEmail(this ClaimsPrincipal user)
1010
{
11-
return user.FindFirst(ClaimTypes.Email)?.Value ?? user.FindFirst("email")?.Value;
11+
return user.FindFirst(ClaimTypes.Email)?.Value
12+
?? user.FindFirst("email")?.Value
13+
?? user.FindFirst(ClaimTypes.Upn)?.Value;
1214
}
1315

1416
public static string? GetCurrentUserRole(ClaimsPrincipal user)

src/Ahk.GradeManagement/Ahk.GradeManagement.Bll/Services/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public async Task<List<SubjectResponse>> GetAllSubjectsByIdAsync(long id)
158158
var email = AuthorizationHelper.GetCurrentUserEmail(httpContextUser);
159159
var currentUser = await gradeManagementDbContext.User
160160
.ProjectTo<Shared.Dtos.User>(mapper.ConfigurationProvider)
161-
.SingleEntityAsync(u => u.BmeEmail == email, 0);
161+
.SingleEntityAsync(u => u.BmeEmail == email, [email]);
162162
return currentUser;
163163
}
164164
}
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<Compile Remove="Utilities\**" />
11+
<Content Remove="Utilities\**" />
12+
<EmbeddedResource Remove="Utilities\**" />
13+
<None Remove="Utilities\**" />
14+
</ItemGroup>
15+
916
<ItemGroup>
1017
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.1" />
1118
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
@@ -14,15 +21,26 @@
1421
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
1522
<PackageReference Include="MudBlazor" Version="7.8.0" />
1623
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
24+
<PackageReference Include="NSwag.MSBuild" Version="14.4.0">
25+
<PrivateAssets>all</PrivateAssets>
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
</PackageReference>
1728
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.0" />
1829
</ItemGroup>
1930

2031
<ItemGroup>
2132
<ProjectReference Include="..\Ahk.GradeManagement.Shared\Ahk.GradeManagement.Shared.csproj" />
2233
</ItemGroup>
2334

24-
<ItemGroup>
25-
<Folder Include="Utilities\" />
26-
</ItemGroup>
35+
<Target Name="NSwag">
36+
<Copy SourceFiles="@(ReferencePath)" DestinationFolder="$(OutDir)References" />
37+
<Exec Command="$(NSwagExe_Net80) run Network/ApiClients.nswag /variables:Configuration=$(Configuration),OutDir=$(OutDir)" />
38+
<RemoveDir Directories="$(OutDir)References" />
39+
</Target>
40+
41+
<Target Name="MakeGenericAgain" AfterTargets="NSwag">
42+
<Exec IgnoreExitCode="true" Command="dotnet tool install --ignore-failed-sources --global makeGenericAgain" />
43+
<Exec Command="makeGenericAgain -f $(ProjectDir)Network\ApiClients.cs -i DateOfGrading" />
44+
</Target>
2745

2846
</Project>

src/Ahk.GradeManagement/Ahk.GradeManagement.Client/Components/Helpers/SubjectExtension.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using Ahk.GradeManagement.Client.Network;
1+
using Ahk.GradeManagement.Shared.Dtos;
2+
using Ahk.GradeManagement.Shared.Dtos.Request;
3+
using Ahk.GradeManagement.Shared.Dtos.Response;
24

35
namespace Ahk.GradeManagement.Client.Components.Helpers;
46

57
public static class Extensions
68
{
7-
public static SubjectRequest ToRequest(this SubjectResponse subject, ICollection<User>? teachers = null)
9+
public static SubjectRequest ToRequest(this SubjectResponse subject, List<User>? teachers = null)
810
{
911
return new SubjectRequest
1012
{
@@ -27,7 +29,7 @@ public static SubjectResponse ToResponse(this SubjectRequest subject)
2729
};
2830
}
2931

30-
public static GroupRequest ToRequest(this GroupResponse group, ICollection<User>? teachers = null)
32+
public static GroupRequest ToRequest(this GroupResponse group, List<User>? teachers = null)
3133
{
3234
return new GroupRequest { Id = group.Id, Name = group.Name, CourseId = group.CourseId, Teachers = teachers };
3335
}
@@ -66,7 +68,7 @@ public static ExerciseResponse ToResponse(this ExerciseRequest exercise)
6668
}
6769

6870

69-
public static StudentRequest ToRequest(this StudentResponse student, ICollection<long>? groupIds = null)
71+
public static StudentRequest ToRequest(this StudentResponse student, List<long>? groupIds = null)
7072
{
7173
return new StudentRequest
7274
{

0 commit comments

Comments
 (0)