57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using Socialize.Api.Modules.Identity.Contracts;
|
|
|
|
namespace Socialize.Api.Modules.Approvals.Services;
|
|
|
|
public static class ApprovalStepTargetTypes
|
|
{
|
|
public const string Role = "Role";
|
|
public const string Membership = "Membership";
|
|
public const string Member = "Member";
|
|
}
|
|
|
|
public static class ApprovalMembershipTargets
|
|
{
|
|
public const string Team = "Team";
|
|
public const string Client = "Client";
|
|
}
|
|
|
|
public static class ApprovalStepConfigurationRules
|
|
{
|
|
public static readonly IReadOnlySet<string> AllowedTargetTypes = new HashSet<string>(StringComparer.Ordinal)
|
|
{
|
|
ApprovalStepTargetTypes.Role,
|
|
ApprovalStepTargetTypes.Membership,
|
|
ApprovalStepTargetTypes.Member,
|
|
};
|
|
|
|
public static readonly IReadOnlySet<string> AllowedRoleTargets = new HashSet<string>(StringComparer.Ordinal)
|
|
{
|
|
KnownRoles.Administrator,
|
|
KnownRoles.Manager,
|
|
KnownRoles.WorkspaceMember,
|
|
KnownRoles.Client,
|
|
KnownRoles.Provider,
|
|
};
|
|
|
|
public static readonly IReadOnlySet<string> AllowedMembershipTargets = new HashSet<string>(StringComparer.Ordinal)
|
|
{
|
|
ApprovalMembershipTargets.Team,
|
|
ApprovalMembershipTargets.Client,
|
|
};
|
|
|
|
public static bool IsValidTargetType(string? targetType)
|
|
{
|
|
return !string.IsNullOrWhiteSpace(targetType) && AllowedTargetTypes.Contains(targetType.Trim());
|
|
}
|
|
|
|
public static bool IsValidRoleTarget(string? targetValue)
|
|
{
|
|
return !string.IsNullOrWhiteSpace(targetValue) && AllowedRoleTargets.Contains(targetValue.Trim());
|
|
}
|
|
|
|
public static bool IsValidMembershipTarget(string? targetValue)
|
|
{
|
|
return !string.IsNullOrWhiteSpace(targetValue) && AllowedMembershipTargets.Contains(targetValue.Trim());
|
|
}
|
|
}
|