- Added custom exceptions: DuplicateResourceException, EntityNotFoundException, AuthenticationFailedException, and BusinessRuleException to improve error handling in the application. - Updated Program.cs to map these exceptions to appropriate HTTP status codes and problem details for better client feedback. - Refactored RegisterUserCommandHandler to throw DuplicateResourceException when a user with the same email already exists. - Enhanced testing setup in CustomWebApplicationFactory to ensure proper handling of these exceptions during functional tests.
14 lines
415 B
C#
14 lines
415 B
C#
using MediatR;
|
|
|
|
namespace IamService.API.Application.Commands.Roles;
|
|
|
|
/// <summary>
|
|
/// EN: Command to assign a role to a user.
|
|
/// VI: Command để gán role cho user.
|
|
/// </summary>
|
|
/// <param name="UserId">User ID / ID của user</param>
|
|
/// <param name="RoleName">Role name to assign / Tên role cần gán</param>
|
|
public record AssignRoleToUserCommand(
|
|
Guid UserId,
|
|
string RoleName) : IRequest<bool>;
|