-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
80 additions
and
91 deletions.
There are no files selected for viewing
11 changes: 3 additions & 8 deletions
11
api/framework/Core/Identity/Roles/Features/CreateOrUpdateRole/CreateOrUpdateRoleCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FSH.Framework.Core.Identity.Roles.Features.CreateOrUpdateRole; | ||
namespace FSH.Framework.Core.Identity.Roles.Features.CreateOrUpdateRole; | ||
|
||
public class CreateOrUpdateRoleCommand | ||
{ | ||
public string Name { get; set; } | ||
public string Id { get; set; } = default!; | ||
public string Name { get; set; } = default!; | ||
public string? Description { get; set; } | ||
} |
7 changes: 0 additions & 7 deletions
7
api/framework/Core/Identity/Roles/Features/DeleteRole/DeleteRoleCommand.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
api/framework/Core/Identity/Roles/Features/DeleteRole/DeleteRoleValidator.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
using FSH.Framework.Core.Identity.Roles.Features; | ||
using FSH.Framework.Core.Identity.Roles.Features.CreateOrUpdateRole; | ||
using FSH.Framework.Core.Identity.Roles.Features.DeleteRole; | ||
using FSH.Framework.Core.Identity.Roles.Features.CreateOrUpdateRole; | ||
|
||
namespace FSH.Framework.Core.Identity.Roles; | ||
|
||
public interface IRoleService | ||
{ | ||
Task<IEnumerable<RoleResponse>> GetAllRolesAsync(); | ||
Task<RoleResponse?> GetRoleByIdAsync(string id); | ||
Task<RoleResponse> CreateOrUpdateRoleAsync(CreateOrUpdateRoleCommand command); | ||
Task DeleteRoleAsync(DeleteRoleCommand command); | ||
Task<IEnumerable<RoleDto>> GetRolesAsync(); | ||
Task<RoleDto?> GetRoleAsync(string id); | ||
Task<RoleDto> CreateOrUpdateRoleAsync(CreateOrUpdateRoleCommand command); | ||
Task DeleteRoleAsync(string id); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace FSH.Framework.Core.Identity.Roles; | ||
|
||
public class RoleDto | ||
{ | ||
public string Id { get; set; } = default!; | ||
public string Name { get; set; } = default!; | ||
public string? Description { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
api/framework/Infrastructure/Identity/Roles/Endpoints/CreateOrUpdateRoleEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FSH.Framework.Core.Identity.Roles; | ||
using FSH.Framework.Core.Identity.Roles; | ||
using FSH.Framework.Core.Identity.Roles.Features.CreateOrUpdateRole; | ||
using FSH.Framework.Infrastructure.Auth.Policy; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
|
||
namespace FSH.Framework.Infrastructure.Identity.Roles.Endpoints; | ||
|
||
public static class CreateOrUpdateRoleEndpoint | ||
{ | ||
public static RouteHandlerBuilder MapCreateOrUpdateRoleEndpoint(this IEndpointRouteBuilder endpoints) | ||
{ | ||
return endpoints.MapPost("/api/roles", async (FshRole role, IRoleService roleService) => | ||
return endpoints.MapPost("/api/roles", async (CreateOrUpdateRoleCommand request, IRoleService roleService) => | ||
{ | ||
var result = await roleService.CreateOrUpdateRoleAsync(role); | ||
return Results.Ok(result); | ||
return await roleService.CreateOrUpdateRoleAsync(request); | ||
}) | ||
.WithName("CreateOrUpdateRole") | ||
.WithSummary("Create or update a role") | ||
.RequirePermission("Permissions.Roles.Create") | ||
.WithDescription("Create a new role or update an existing role."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
api/framework/Infrastructure/Identity/Roles/Endpoints/Extensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.AspNetCore.Routing; | ||
|
||
namespace FSH.Framework.Infrastructure.Identity.Roles.Endpoints; | ||
|
||
internal static class Extensions | ||
{ | ||
public static IEndpointRouteBuilder MapRoleEndpoints(this IEndpointRouteBuilder app) | ||
{ | ||
app.MapGetRoleEndpoint(); | ||
app.MapGetRolesEndpoint(); | ||
app.MapDeleteRoleEndpoint(); | ||
app.MapCreateOrUpdateRoleEndpoint(); | ||
return app; | ||
} | ||
} | ||
|
16 changes: 6 additions & 10 deletions
16
api/framework/Infrastructure/Identity/Roles/Endpoints/GetRoleEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
api/framework/Infrastructure/Identity/Roles/Endpoints/GetRolesEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
api/framework/Infrastructure/Identity/Users/Endpoints/GetUserProfileEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters