diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Design.cshtml b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Design.cshtml index a685e7d9459..b22755e982f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Design.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Design.cshtml @@ -2,7 +2,9 @@ @using OrchardCore.Workflows.Helpers @using OrchardCore.Roles.Workflows.Activities @using OrchardCore.Roles.Workflows.ViewModels + @model ActivityViewModel +

@Model.Activity.GetTitleOrDefault(() => T["Get users in roles"]) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Edit.cshtml index a23bc783deb..e127ea6f91a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/GetUsersByRoleTask.Fields.Edit.cshtml @@ -1,4 +1,5 @@ @using OrchardCore.Roles.Workflows.ViewModels + @model GetUsersByRoleTaskViewModel
diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/UnassignUserRoleTask.Fields.Design.cshtml b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/UnassignUserRoleTask.Fields.Design.cshtml index acbf415abbf..8476667d3f6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/UnassignUserRoleTask.Fields.Design.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Items/UnassignUserRoleTask.Fields.Design.cshtml @@ -2,7 +2,9 @@ @using OrchardCore.Workflows.Helpers @using OrchardCore.Roles.Workflows.Activities @using OrchardCore.Roles.Workflows.ViewModels + @model ActivityViewModel +

@Model.Activity.GetTitleOrDefault(() => T["Unassign user from roles"]) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/GetUsersByRoleTask.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/GetUsersByRoleTask.cs index 4fe0ffa47dd..6bc17d1e86c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/GetUsersByRoleTask.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/GetUsersByRoleTask.cs @@ -12,7 +12,7 @@ namespace OrchardCore.Roles.Workflows.Activities; -public class GetUsersByRoleTask : TaskActivity +public class GetUsersByRoleTask : TaskActivity { private readonly UserManager _userManager; private readonly IWorkflowExpressionEvaluator _expressionEvaluator; @@ -25,8 +25,6 @@ public GetUsersByRoleTask(UserManager userManager, IWorkflowExpressionEva S = localizer; } - public override string Name => nameof(GetUsersByRoleTask); - public override LocalizedString DisplayText => S["Get Users by Role Task"]; public override LocalizedString Category => S["User"]; @@ -49,11 +47,12 @@ public override IEnumerable GetPossibleOutcomes(WorkflowExecutionContex public override async Task ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext) { - var propKeyName = await _expressionEvaluator.EvaluateAsync(OutputKeyName, workflowContext, null); + var outputKeyName = await _expressionEvaluator.EvaluateAsync(OutputKeyName, workflowContext, null); if (!string.IsNullOrEmpty(propKeyName)) { - var usersInRole = new List(); + var usersInRole = new Dictionary(); + foreach (var role in Roles) { foreach(var u in await _userManager.GetUsersInRoleAsync(role)) @@ -63,15 +62,13 @@ public override async Task ExecuteAsync(WorkflowExecuti continue; } - usersInRole.Add(user); + usersInRole.TryAdd(user.UserId, user); } } - if (usersInRole.Count > 0) - { - workflowContext.Output[propKeyName] = usersInRole; + + workflowContext.Output[outputKeyName] = usersInRole.Values; - return Outcomes("Done"); - } + return Outcomes("Done"); } return Outcomes("Failed"); diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/UnassignUserRoleTask.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/UnassignUserRoleTask.cs index 41f52b9b7e8..17e6ab7a343 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/UnassignUserRoleTask.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Views/Workflows/Activities/UnassignUserRoleTask.cs @@ -13,7 +13,7 @@ namespace OrchardCore.Roles.Workflows.Activities; -public class UnassignUserRoleTask : TaskActivity +public class UnassignUserRoleTask : TaskActivity { private readonly UserManager _userManager; private readonly IUserService _userService; @@ -28,8 +28,6 @@ public UnassignUserRoleTask(UserManager userManager, IUserService userSer S = localizer; } - public override string Name => nameof(UnassignUserRoleTask); - public override LocalizedString DisplayText => S["Unassign User Role Task"]; public override LocalizedString Category => S["User"];