protected async Task AddAsync() { _messageStore.Clear(); var userId = await UserApiService.GetUserIdAsync(Username); var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId(); if (userId == loggedInUserId) { _messageStore.Add(CurrentEditContext.Field("Username"), "Adding yourself is not allowed."); CurrentEditContext.NotifyValidationStateChanged(); return; } if (string.IsNullOrEmpty(userId)) { _messageStore.Add(CurrentEditContext.Field("Username"), $"{Username} not found"); CurrentEditContext.NotifyValidationStateChanged(); return; } if (Members.Any(m => m[0] == userId)) { _messageStore.Add(CurrentEditContext.Field("Username"), $"{Username} already added."); CurrentEditContext.NotifyValidationStateChanged(); return; } Members.Add(new string[] { userId, Username }); await OnUpdateUsers.InvokeAsync(Members); }