Browse Source

Update How-To-Add-Custom-Property-To-The-User-Entity.md

pull/5734/head
Berkan Sasmaz 6 years ago
committed by GitHub
parent
commit
5db3a31fa1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      docs/en/Community-Articles/2020-10-08-How-To-Add-Custom-Property-To-The-User-Entity/How-To-Add-Custom-Property-To-The-User-Entity.md

16
docs/en/Community-Articles/2020-10-08-How-To-Add-Custom-Property-To-The-User-Entity/How-To-Add-Custom-Property-To-The-User-Entity.md

@ -47,7 +47,7 @@ public int Reputation { get; protected set; }
Create the Users folder in the **CustomizeUserDemo.Domain.Shared** project, create the class `UserConsts` inside the folder and update the class you created as below: Create the Users folder in the **CustomizeUserDemo.Domain.Shared** project, create the class `UserConsts` inside the folder and update the class you created as below:
```csharp ```csharp
public class UserConst public static class UserConsts
{ {
public const string TitlePropertyName = "Title"; public const string TitlePropertyName = "Title";
@ -83,13 +83,13 @@ public static class CustomizeUserDemoEfCoreEntityExtensionMappings
(entityBuilder, propertyBuilder) => (entityBuilder, propertyBuilder) =>
{ {
propertyBuilder.IsRequired(); propertyBuilder.IsRequired();
propertyBuilder.HasMaxLength(UserConst.MaxTitleLength); propertyBuilder.HasMaxLength(UserConsts.MaxTitleLength);
} }
).MapEfCoreProperty<IdentityUser, int>( ).MapEfCoreProperty<IdentityUser, int>(
nameof(AppUser.Reputation), nameof(AppUser.Reputation),
(entityBuilder, propertyBuilder) => (entityBuilder, propertyBuilder) =>
{ {
propertyBuilder.HasDefaultValue(UserConst.MinReputationValue); propertyBuilder.HasDefaultValue(UserConsts.MinReputationValue);
} }
); );
}); });
@ -133,22 +133,22 @@ private static void ConfigureExtraProperties()
identity.ConfigureUser(user => identity.ConfigureUser(user =>
{ {
user.AddOrUpdateProperty<string>( user.AddOrUpdateProperty<string>(
UserConst.TitlePropertyName, UserConsts.TitlePropertyName,
options => options =>
{ {
options.Attributes.Add(new RequiredAttribute()); options.Attributes.Add(new RequiredAttribute());
options.Attributes.Add( options.Attributes.Add(
new StringLengthAttribute(UserConst.MaxTitleLength) new StringLengthAttribute(UserConsts.MaxTitleLength)
); );
} }
); );
user.AddOrUpdateProperty<int>( user.AddOrUpdateProperty<int>(
UserConst.ReputationPropertyName, UserConsts.ReputationPropertyName,
options => options =>
{ {
options.DefaultValue = UserConst.MinReputationValue; options.DefaultValue = UserConsts.MinReputationValue;
options.Attributes.Add( options.Attributes.Add(
new RangeAttribute(UserConst.MinReputationValue, UserConst.MaxReputationValue) new RangeAttribute(UserConsts.MinReputationValue, UserConsts.MaxReputationValue)
); );
} }
); );

Loading…
Cancel
Save