@if (!IsLoading)
{
@foreach (var user in UserList.Users ?? [])
{
-
+
}
}
else
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
index 8a7677f..f6d9bbb 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.cs
@@ -16,6 +16,7 @@ public partial class Users
private UserListDto UserList = new();
private IEnumerable
Roles = [];
private int CurrentPage = 1;
+ private UserDto UserAdd = new();
protected override async Task OnInitializedAsync()
{
@@ -43,12 +44,72 @@ public partial class Users
IsLoading = false;
}
}
- private Task HandleSubmitUser(UserDto args)
+
+ private async Task HandleSubmitUser(UserDto user)
{
- throw new NotImplementedException();
+ try
+ {
+ IsLoading = true;
+
+ await UserGateway.CreateUser(user);
+ await FetchData(false);
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+
+ UserAdd = new();
}
- private Task HandleRemoveUser(UserDto args)
+
+ private async Task HandleUpdateUser(UserDto user)
{
- throw new NotImplementedException();
+ try
+ {
+ IsLoading = true;
+
+ await UserGateway.UpdateUser(user);
+ await FetchData(false);
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+ }
+
+ private async Task HandleRemoveUser(UserDto user)
+ {
+ if (user.Id == null)
+ {
+ return;
+ }
+
+ try
+ {
+ IsLoading = true;
+
+ await UserGateway.DeleteUser(user.Id);
+ await FetchData(false);
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+ }
+ private void HandleResetUser(UserDto args)
+ {
+ UserAdd = new();
}
}
\ No newline at end of file
diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.css b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.css
index 18bbb60..0bbbd2d 100644
--- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.css
+++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Users/Users.razor.css
@@ -4,13 +4,19 @@
gap: 8px;
}
-::deep .search-container .select-container {
+::deep .search-container, ::deep .select-container {
box-sizing: border-box;
max-width: 200px;
}
.container {
padding: 20px 200px;
+ display: grid;
+ grid-gap: 20px;
+}
+
+.line {
+ border: 1px solid var(--line);
}
.content {
diff --git a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs
index 3801e02..9d9176d 100644
--- a/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs
+++ b/src/GameIdeas/GameIdeas.Shared/Constants/GlobalConstants.cs
@@ -7,7 +7,9 @@ public class GlobalConstants
public readonly static Guid MEMBER_ID = Guid.Parse("{BCE14DEA-1748-4A76-8485-ADEE83DF5EFD}");
public const string ADMINISTRATOR = "Administrateur";
+ public const string ADMINISTRATOR_NORMALIZED = "ADMINISTRATEUR";
public const string MEMBER = "Membre";
+ public const string MEMBER_NORMALIZED = "MEMBRE";
public const string ADMIN_MEMBER = $"{ADMINISTRATOR}, {MEMBER}";
public const int JWT_DURATION_HOUR = 12;
diff --git a/src/GameIdeas/GameIdeas.Shared/Dto/IdDto.cs b/src/GameIdeas/GameIdeas.Shared/Dto/IdDto.cs
new file mode 100644
index 0000000..5b05142
--- /dev/null
+++ b/src/GameIdeas/GameIdeas.Shared/Dto/IdDto.cs
@@ -0,0 +1,6 @@
+namespace GameIdeas.Shared.Dto;
+
+public class IdDto
+{
+ public string? Id { get; set; }
+}
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
index ba76f3d..90a03ac 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/UserController.cs
@@ -72,11 +72,12 @@ public class UserController(
[Authorize(Roles = GlobalConstants.ADMINISTRATOR)]
[HttpPost("Create")]
- public async Task> CreateUser([FromBody] UserDto user)
+ public async Task> CreateUser([FromBody] UserDto user)
{
try
{
- return Created("/Create", await userWriteService.CreateUser(user));
+ var id = new IdDto() { Id = await userWriteService.CreateUser(user) };
+ return Created("/Create", id);
}
catch (Exception e)
{
@@ -87,11 +88,12 @@ public class UserController(
[Authorize(Roles = GlobalConstants.ADMINISTRATOR)]
[HttpPut("Update/{userId}")]
- public async Task> UpdateUser(string userId, [FromBody] UserDto user)
+ public async Task> UpdateUser(string userId, [FromBody] UserDto user)
{
try
{
- return Created("/Update", await userWriteService.UpdateUser(userId, user));
+ var id = new IdDto() { Id = await userWriteService.UpdateUser(userId, user) };
+ return Created("/Update", id);
}
catch (Exception e)
{
@@ -102,11 +104,12 @@ public class UserController(
[Authorize(Roles = GlobalConstants.ADMINISTRATOR)]
[HttpDelete("Delete/{userId}")]
- public async Task> DeleteUser(string userId)
+ public async Task> DeleteUser(string userId)
{
try
{
- return Created("/Delete", await userWriteService.DeleteUser(userId));
+ var id = new IdDto() { Id = await userWriteService.DeleteUser(userId) };
+ return Created("/Delete", id);
}
catch (Exception e)
{
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
index 85a47ed..2a321a9 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Migrations/20250420160158_SeedDefaultUser.cs
@@ -19,13 +19,13 @@ namespace GameIdeas.WebAPI.Migrations
{
GlobalConstants.ADMINISTRATOR_ID.ToString(),
GlobalConstants.ADMINISTRATOR,
- GlobalConstants.ADMINISTRATOR.Normalize(),
+ GlobalConstants.ADMINISTRATOR_NORMALIZED,
Guid.NewGuid().ToString()
},
{
GlobalConstants.MEMBER_ID.ToString(),
GlobalConstants.MEMBER,
- GlobalConstants.MEMBER.Normalize(),
+ GlobalConstants.MEMBER_NORMALIZED,
Guid.NewGuid().ToString()
}
});
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
index 1bd9aa5..2378126 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Program.cs
@@ -59,6 +59,17 @@ services.AddAuthentication(options =>
};
});
+services.Configure(options =>
+{
+ // Default Password settings.
+ options.Password.RequireDigit = false;
+ options.Password.RequireLowercase = false;
+ options.Password.RequireNonAlphanumeric = false;
+ options.Password.RequireUppercase = false;
+ options.Password.RequiredLength = 6;
+ options.Password.RequiredUniqueChars = 1;
+});
+
services.AddAuthorization();
services.AddSingleton();
diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
index 404a883..88c4524 100644
--- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
+++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/Users/UserWriteService.cs
@@ -29,7 +29,7 @@ public class UserWriteService(
}
else
{
- throw new UserInvalidException(string.Join("; ", result.Errors));
+ throw new UserInvalidException(string.Join("; ", result.Errors.Select(e => $"{e.Code} {e.Description}")));
}
return userToCreate.Id;