namespace OmsorgCore.Application.Services;

public enum CreateUserFailureReason
{
    EmployeeNotFound,
    EmployeeAlreadyHasAccount,
    EmployeeEmailMissing,
    UsernameTaken,
    RoleNotFound,
    InitialPasswordRequired,
    PasswordTooShort
}

public class CreateUserResult
{
    public bool Success { get; init; }
    public CreateUserFailureReason? FailureReason { get; init; }
    public Guid? UserId { get; init; }
    public string? RoleName { get; init; }

    /// <summary>Nur im Invite-Modus gesetzt - für den Versand der Einladungsmail.</summary>
    public string? Email { get; init; }
    public string? RawInvitePin { get; init; }

    public static CreateUserResult Fail(CreateUserFailureReason reason) => new()
    {
        Success = false,
        FailureReason = reason
    };

    public static CreateUserResult Ok(Guid userId, string roleName, string? email = null, string? rawInvitePin = null) => new()
    {
        Success = true,
        UserId = userId,
        RoleName = roleName,
        Email = email,
        RawInvitePin = rawInvitePin
    };
}
