Compare commits

...

3 Commits

Author SHA1 Message Date
a.beging@eas-solutions.de
8df4abc8a3 Fix EditProspectDialog: update NumericEdit to handle null Foodsharing-ID correctly
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 2m15s
2026-05-12 10:07:11 +02:00
a.beging@eas-solutions.de
bf69880d5f Fix GetAttributeOfType method: add check for empty member info to prevent null reference exceptions 2026-05-12 10:07:01 +02:00
a.beging@eas-solutions.de
c6178ecacd Fix User class: enhance GroupsList property to safely parse UserGroup enums 2026-05-12 10:06:52 +02:00
3 changed files with 8 additions and 2 deletions

View File

@@ -42,7 +42,12 @@ namespace FoodsharingSiegen.Contracts.Entity
{ {
if (string.IsNullOrWhiteSpace(Groups)) return new List<UserGroup>(); if (string.IsNullOrWhiteSpace(Groups)) return new List<UserGroup>();
var stringList = Groups.Split(","); var stringList = Groups.Split(",");
var enumList = stringList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(Enum.Parse<UserGroup>).ToList(); var enumList = stringList
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(x => Enum.TryParse<UserGroup>(x.Trim(), out var result) ? result : (UserGroup?)null)
.Where(x => x.HasValue)
.Select(x => x!.Value)
.ToList();
return enumList; return enumList;
} }
set => Groups = string.Join(",", value); set => Groups = string.Join(",", value);

View File

@@ -34,6 +34,7 @@ namespace FoodsharingSiegen.Contracts.Helper
{ {
var type = enumVal.GetType(); var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString()); var memInfo = type.GetMember(enumVal.ToString());
if (memInfo.Length == 0) return null;
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
return attributes.Length > 0 ? (T)attributes[0] : null; return attributes.Length > 0 ? (T)attributes[0] : null;
} }

View File

@@ -11,7 +11,7 @@
<div class="col"> <div class="col">
<Field> <Field>
<FieldLabel>Foodsharing-ID</FieldLabel> <FieldLabel>Foodsharing-ID</FieldLabel>
<NumericEdit TValue="int?" Value="Prospect.FsId" ValueChanged="@((int? v) => Prospect.FsId = v ?? 0)"></NumericEdit> <NumericEdit TValue="int?" Value="@(Prospect.FsId == 0 ? (int?)null : Prospect.FsId)" ValueChanged="@((int? v) => Prospect.FsId = v ?? 0)"></NumericEdit>
</Field> </Field>
</div> </div>
</div> </div>