set your activity country
All checks were successful
Forgejo Release / release (push) Successful in 10m6s

This commit is contained in:
Paul Schneider 2026-08-31 05:40:34 +01:00
commit b642cbf067
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
8 changed files with 5096 additions and 21 deletions

View file

@ -568,7 +568,17 @@ namespace Yavsc.Controllers
{
var user = GetCurrentUserAsync().Result;
var uid = user.Id;
var postedCountryCode = model.ExerciseCountryCode;
model.ExerciseCountryCode = NormalizeCountryCodeOrDefault(model.ExerciseCountryCode);
// Model binding validated the raw posted payload before entering
// the action. If country was empty, we fallback to "fr" above,
// so remove the stale min-length error attached to the empty value.
if (string.IsNullOrWhiteSpace(postedCountryCode))
{
ModelState.Remove(nameof(PerformerProfile.ExerciseCountryCode));
}
try
{
if (ModelState.IsValid)
@ -636,7 +646,7 @@ namespace Yavsc.Controllers
return View(model);
}
private static string NormalizeCountryCodeOrDefault(string? code)
private static string NormalizeCountryCodeOrDefault(string code)
{
var normalized = PerformerCodeInputValidationCatalog.NormalizeCountryCode(code);
if (string.IsNullOrWhiteSpace(normalized))
@ -647,14 +657,17 @@ namespace Yavsc.Controllers
return normalized;
}
private void SetExerciseCountries(string? selectedCountryCode)
private void SetExerciseCountries(string selectedCountryCode)
{
var selected = NormalizeCountryCodeOrDefault(selectedCountryCode);
ViewBag.ExerciseCountries = new SelectList(
var countries = new SelectList(
PerformerCodeInputValidationCatalog.Countries,
nameof(Country.Code),
nameof(Country.DisplayName),
selected);
ViewBag.ExerciseCountries = countries;
ViewBag.Countries = countries;
ViewBag.CountryCodeValidationRules = PerformerCodeInputValidationCatalog.Rules;
}
[HttpPost]