diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs new file mode 100644 index 0000000000..0c6b9dff67 --- /dev/null +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs @@ -0,0 +1,30 @@ +using System; + +namespace Volo.Abp.Data +{ + public static class ExtraPropertyDictionaryExtensions + { + public static T ToEnum(this ExtraPropertyDictionary extraPropertyDictionary, string key) + where T : Enum + { + if (extraPropertyDictionary[key].GetType() == typeof(T)) + { + return (T)extraPropertyDictionary[key]; + } + + extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key].ToString(), ignoreCase: true); + return (T)extraPropertyDictionary[key]; + } + + public static object ToEnum(this ExtraPropertyDictionary extraPropertyDictionary, string key, Type enumType) + { + if (!enumType.IsEnum || extraPropertyDictionary[key].GetType() == enumType) + { + return extraPropertyDictionary[key]; + } + + extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key].ToString(), ignoreCase: true); + return extraPropertyDictionary[key]; + } + } +} diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml index 02a24b4084..4ebac325fb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml @@ -30,6 +30,10 @@ { if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty()) { + if (propertyInfo.Type.IsEnum) + { + Model.Role.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type); + }