Allow amateur performer profiles

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-11-08 02:29:09 +00:00
commit 0728d2a3f7
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
20 changed files with 217 additions and 29 deletions

View file

@ -1,15 +1,18 @@
#nullable enable
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using Yavsc.Models.Workflow;
namespace Yavsc.Abstract.Workflow;
public sealed class PerformerProfileSettings
public sealed class PerformerProfileSettings : IValidatableObject
{
public string PerformerId { get; set; } = string.Empty;
public string UserName { get; set; } = string.Empty;
public string ExerciseCountryCode { get; set; } = "fr";
public string SIREN { get; set; } = string.Empty;
public bool CanIssueEstimates => !string.IsNullOrWhiteSpace(SIREN);
public string WebSite { get; set; } = string.Empty;
/// <summary>Owner-only PayPal recipient. Null preserves the existing setting; empty disables donations.</summary>
[MaxLength(127)]
@ -19,4 +22,24 @@ public sealed class PerformerProfileSettings
public bool AcceptPublicContact { get; set; }
public bool UseGeoLocalizationToReduceDistanceWithClients { get; set; }
public List<string> SelectedActivityCodes { get; set; } = new();
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var countryCode = PerformerCodeInputValidationCatalog.NormalizeCountryCode(
string.IsNullOrWhiteSpace(ExerciseCountryCode) ? "fr" : ExerciseCountryCode);
var rule = PerformerCodeInputValidationCatalog.GetRule(countryCode);
if (rule is null)
{
yield return new ValidationResult(
"Le pays d'exercice doit etre l'un des suivants: fr, en, pt.",
new[] { nameof(ExerciseCountryCode) });
yield break;
}
if (!string.IsNullOrWhiteSpace(SIREN)
&& !Regex.IsMatch(SIREN.Trim(), rule.RegularExpression, RegexOptions.CultureInvariant))
{
yield return new ValidationResult(rule.ErrorMessage, new[] { nameof(SIREN) });
}
}
}