Refactor Users page: update Autocomplete selection mode and fix user service methods to use OldItem for adding and updating users

This commit is contained in:
a.beging@eas-solutions.de
2026-04-23 15:44:27 +02:00
parent 94a2dbf801
commit b1ed916da4
3 changed files with 7 additions and 7 deletions

View File

@@ -92,9 +92,9 @@
Data="@UserGroups" Data="@UserGroups"
TextField="@(( item ) => item.ToString())" TextField="@(( item ) => item.ToString())"
ValueField="@(( item ) => item)" ValueField="@(( item ) => item)"
Multiple="true" SelectionMode="AutocompleteSelectionMode.Multiple"
SelectedValues="@((List<UserGroup>) context.CellValue)" SelectedValues="@((List<UserGroup>) context.CellValue)"
SelectedValuesChanged="@(v => context.CellValue = v)" SelectedValuesChanged="@(v => { context.CellValue = v.ToList(); })"
@bind-SelectedTexts="SelectedCompanyTexts"> @bind-SelectedTexts="SelectedCompanyTexts">
</Autocomplete> </Autocomplete>
<small>Verfügbar: @string.Join(", ", Enum.GetValues<UserGroup>())</small> <small>Verfügbar: @string.Join(", ", Enum.GetValues<UserGroup>())</small>

View File

@@ -134,7 +134,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <param name="arg">The arg</param> /// <param name="arg">The arg</param>
private async Task RowInserted(SavedRowItem<User, Dictionary<string, object>> arg) private async Task RowInserted(SavedRowItem<User, Dictionary<string, object>> arg)
{ {
var addUserR = await UserService.AddUserAsync(arg.Item); var addUserR = await UserService.AddUserAsync(arg.OldItem);
if (!addUserR.Success) if (!addUserR.Success)
await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!; await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
else else
@@ -151,9 +151,9 @@ namespace FoodsharingSiegen.Server.Pages
/// <param name="arg">The arg</param> /// <param name="arg">The arg</param>
private async Task RowUpdated(SavedRowItem<User, Dictionary<string, object>> arg) private async Task RowUpdated(SavedRowItem<User, Dictionary<string, object>> arg)
{ {
if (arg.Item?.Id == null || arg.Item.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return; if (arg.OldItem?.Id == null || arg.OldItem.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return;
var updateR = await UserService.Update(arg.Item); var updateR = await UserService.Update(arg.OldItem);
if (!updateR.Success) if (!updateR.Success)
await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!; await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!;
} }

View File

@@ -24,5 +24,5 @@
</NotAuthorized> </NotAuthorized>
</AuthorizeView> </AuthorizeView>
<NotificationAlert/> <NotificationProvider/>
<MessageAlert/> <MessageProvider/>