@attribute [Authorize] @inherits AuthComponentBase @inject IDataService DataService @inject IToastService ToastService
Editing @EditUser?.UserName
@foreach (var group in DeviceGroups ?? Array.Empty()) {
} @code { public static string EditUserPropName => nameof(EditUser); public static string DeviceGroupsPropName => nameof(DeviceGroups); [Parameter] public RemotelyUser EditUser { get; set; } [Parameter] public DeviceGroup[] DeviceGroups { get; set; } private bool DoesGroupContainUser(DeviceGroup group) { return group.Users.Any(x => x.Id == EditUser.Id); } private async Task GroupCheckChanged(ChangeEventArgs args, DeviceGroup group) { if ((bool)args.Value) { if (!DataService.AddUserToDeviceGroup(EditUser.OrganizationID, group.ID, EditUser.UserName, out var result)) { ToastService.ShowToast(result, classString: "bg-warning"); } else { ToastService.ShowToast("User added to group."); } } else { var result = await DataService.RemoveUserFromDeviceGroup(EditUser.OrganizationID, group.ID, EditUser.Id); if (!result) { ToastService.ShowToast("Failed to remove from group.", classString: "bg-warning"); } else { ToastService.ShowToast("Removed user from group."); } } } }