From 0200e5e340971cd9d716f082d37251fb0d9fc811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 20 Mar 2020 14:19:56 +0300 Subject: [PATCH] Use automapper to map IdentityUser to UserEto --- .../Abp/Identity/AbpIdentityDomainModule.cs | 2 +- .../Identity/IdentityDomainMappingProfile.cs | 2 ++ .../Volo/Abp/Identity/IdentityUser.cs | 34 +------------------ 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs index b0b3dad266..12af875bab 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs @@ -29,7 +29,7 @@ namespace Volo.Abp.Identity Configure(options => { - options.EtoMappings.Add(); + options.EtoMappings.Add(typeof(AbpIdentityDomainModule)); options.EtoMappings.Add(typeof(AbpIdentityDomainModule)); options.EtoMappings.Add(typeof(AbpIdentityDomainModule)); }); diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs index 8b7296242b..547525b46e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Volo.Abp.Users; namespace Volo.Abp.Identity { @@ -6,6 +7,7 @@ namespace Volo.Abp.Identity { public IdentityDomainMappingProfile() { + CreateMap(); CreateMap(); CreateMap(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs index c6ad077456..51e15339ee 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs @@ -8,12 +8,11 @@ using Microsoft.AspNetCore.Identity; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Guids; -using Volo.Abp.ObjectMapping; using Volo.Abp.Users; namespace Volo.Abp.Identity { - public class IdentityUser : FullAuditedAggregateRoot, IUser, IMapTo + public class IdentityUser : FullAuditedAggregateRoot, IUser { public virtual Guid? TenantId { get; protected set; } @@ -281,36 +280,5 @@ namespace Volo.Abp.Identity { return $"{base.ToString()}, UserName = {UserName}"; } - - UserEto IMapTo.MapTo() - { - //TODO: Instead, consider to use automapper (but it makes dependency just for a small code part)?? - - return new UserEto - { - Name = Name, - Email = Email, - EmailConfirmed = EmailConfirmed, - Id = Id, - PhoneNumber = PhoneNumber, - PhoneNumberConfirmed = PhoneNumberConfirmed, - Surname = Surname, - TenantId = TenantId, - UserName = UserName - }; - } - - void IMapTo.MapTo(UserEto destination) - { - destination.Name = Name; - destination.Email = Email; - destination.EmailConfirmed = EmailConfirmed; - destination.Id = Id; - destination.PhoneNumber = PhoneNumber; - destination.PhoneNumberConfirmed = PhoneNumberConfirmed; - destination.Surname = Surname; - destination.TenantId = TenantId; - destination.UserName = UserName; - } } }