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