|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using Volo.Abp.Identity;
|
|
|
|
|
using Volo.Abp.Localization;
|
|
|
|
|
using Volo.Abp.ObjectExtending;
|
|
|
|
|
using Volo.Abp.Threading;
|
|
|
|
|
|
|
|
|
|
@ -36,46 +35,38 @@ namespace MyCompanyName.MyProjectName
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ConfigureExtraProperties()
|
|
|
|
|
private static void ConfigureExtraProperties()
|
|
|
|
|
{
|
|
|
|
|
OneTimeRunner.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
ObjectExtensionManager.Instance.Modules()
|
|
|
|
|
.ConfigureIdentity(identity =>
|
|
|
|
|
{
|
|
|
|
|
identity.ConfigureUser(user =>
|
|
|
|
|
{
|
|
|
|
|
user.AddOrUpdateProperty<string>( //property type: string
|
|
|
|
|
"SocialSecurityNumber", //property name
|
|
|
|
|
property =>
|
|
|
|
|
{
|
|
|
|
|
//validation rules
|
|
|
|
|
property.Attributes.Add(new RequiredAttribute());
|
|
|
|
|
property.Attributes.Add(
|
|
|
|
|
new StringLengthAttribute(64) {
|
|
|
|
|
MinimumLength = 4
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
/* You can configure extra properties for the
|
|
|
|
|
* entities defined in the modules used by your application.
|
|
|
|
|
*
|
|
|
|
|
* This class can be used to define these extra properties
|
|
|
|
|
* with a high level, easy to use API.
|
|
|
|
|
*
|
|
|
|
|
* Example: Add a new property to the user entity of the identity module
|
|
|
|
|
|
|
|
|
|
property.UI.OnTable.IsVisible = false;
|
|
|
|
|
ObjectExtensionManager.Instance.Modules()
|
|
|
|
|
.ConfigureIdentity(identity =>
|
|
|
|
|
{
|
|
|
|
|
identity.ConfigureUser(user =>
|
|
|
|
|
{
|
|
|
|
|
user.AddOrUpdateProperty<string>( //property type: string
|
|
|
|
|
"SocialSecurityNumber", //property name
|
|
|
|
|
property =>
|
|
|
|
|
{
|
|
|
|
|
//validation rules
|
|
|
|
|
property.Attributes.Add(new RequiredAttribute());
|
|
|
|
|
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
|
|
|
|
|
|
|
|
|
|
property.Validators.Add(context =>
|
|
|
|
|
{
|
|
|
|
|
if (((string) context.Value).StartsWith("B"))
|
|
|
|
|
{
|
|
|
|
|
context.ValidationErrors.Add(
|
|
|
|
|
new ValidationResult(
|
|
|
|
|
"Social security number can not start with the letter 'B', sorry!",
|
|
|
|
|
new[] {"extraProperties.SocialSecurityNumber"}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
//...other configurations for this property
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
* See the documentation for more:
|
|
|
|
|
* https://docs.abp.io/en/latest/Module-Entity-Extensions
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|