diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs index 64049635bc..15f057db8a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs @@ -1,11 +1,12 @@ -using Volo.Abp.AutoMapper; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement; namespace Volo.Abp.Identity { [DependsOn( - typeof(AbpIdentityDomainModule), + typeof(AbpIdentityDomainModule), typeof(AbpIdentityApplicationContractsModule), typeof(AbpAutoMapperModule), typeof(AbpPermissionManagementApplicationModule) @@ -14,6 +15,8 @@ namespace Volo.Abp.Identity { public override void ConfigureServices(ServiceConfigurationContext context) { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { options.AddProfile(validate: true); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityAppServiceBase.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityAppServiceBase.cs index 0c98e5b5dd..4c01a885c0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityAppServiceBase.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityAppServiceBase.cs @@ -1,9 +1,14 @@ using Volo.Abp.Application.Services; +using Volo.Abp.Identity.Localization; namespace Volo.Abp.Identity { public abstract class IdentityAppServiceBase : ApplicationService { - + protected IdentityAppServiceBase() + { + ObjectMapperContext = typeof(AbpIdentityApplicationModule); + LocalizationResource = typeof(IdentityResource); + } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index 939d9739d2..8cdeac0ce2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -4,14 +4,11 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Volo.Abp.Application.Dtos; -using Volo.Abp.Application.Services; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.PermissionManagement; namespace Volo.Abp.Identity { [Authorize(IdentityPermissions.Roles.Default)] - public class IdentityRoleAppService : ApplicationService, IIdentityRoleAppService + public class IdentityRoleAppService : IdentityAppServiceBase, IIdentityRoleAppService { private readonly IdentityRoleManager _roleManager; private readonly IIdentityRoleRepository _roleRepository; 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 304662a99c..938b4050d7 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 @@ -4,11 +4,8 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Volo.Abp.Domain; using Volo.Abp.EventBus.Distributed; -using Volo.Abp.Identity.Localization; -using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Users; -using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.Identity { 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 f75bf32aaf..23632efce0 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 @@ -283,7 +283,7 @@ namespace Volo.Abp.Identity UserEto IMapTo.MapTo() { - //TODO: Instead, consider to user automapper (but it makes dependency just for a small code part)?? + //TODO: Instead, consider to use automapper (but it makes dependency just for a small code part)?? return new UserEto { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index 077499c48e..1fe917221f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -1,16 +1,11 @@ -using Localization.Resources.AbpUi; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; -using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling; using Volo.Abp.AutoMapper; using Volo.Abp.Identity.Localization; using Volo.Abp.Identity.Web.Navigation; -using Volo.Abp.Localization; -using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.Web; using Volo.Abp.UI.Navigation; @@ -45,6 +40,8 @@ namespace Volo.Abp.Identity.Web options.FileSets.AddEmbedded("Volo.Abp.Identity.Web"); }); + context.Services.AddAutoMapperObjectMapper(); + Configure(options => { options.AddProfile(validate: true); diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/IdentityPageModel.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/IdentityPageModel.cs new file mode 100644 index 0000000000..fab6685d07 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/IdentityPageModel.cs @@ -0,0 +1,12 @@ +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; + +namespace Volo.Abp.Identity.Web.Pages.Identity +{ + public abstract class IdentityPageModel : AbpPageModel + { + protected IdentityPageModel() + { + ObjectMapperContext = typeof(AbpIdentityWebModule); + } + } +} diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs index 7477439821..b3fdad3a95 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs @@ -1,11 +1,10 @@ using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace Volo.Abp.Identity.Web.Pages.Identity.Roles { - public class CreateModalModel : AbpPageModel + public class CreateModalModel : IdentityPageModel { [BindProperty] public RoleInfoModel Role { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs index 66259c6ba0..8416e171b0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs @@ -2,12 +2,11 @@ using System; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity.Web.Pages.Identity.Roles { - public class EditModalModel : AbpPageModel + public class EditModalModel : IdentityPageModel { [BindProperty] public RoleInfoModel Role { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs index 11e84ed0b0..db83e82003 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs @@ -1,8 +1,6 @@ -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; - namespace Volo.Abp.Identity.Web.Pages.Identity.Roles { - public class IndexModel : AbpPageModel + public class IndexModel : IdentityPageModel { public void OnGet() { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index 4d36736501..3c5451208a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -3,11 +3,10 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; namespace Volo.Abp.Identity.Web.Pages.Identity.Users { - public class CreateModalModel : AbpPageModel + public class CreateModalModel : IdentityPageModel { [BindProperty] public UserInfoViewModel UserInfo { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 1b166b881f..771b4fbcd9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -4,12 +4,11 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity.Web.Pages.Identity.Users { - public class EditModalModel : AbpPageModel + public class EditModalModel : IdentityPageModel { [BindProperty] public UserInfoViewModel UserInfo { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs index fa1e8e16af..c8d4e84e82 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs @@ -1,8 +1,6 @@ -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; - -namespace Volo.Abp.Identity.Web.Pages.Identity.Users +namespace Volo.Abp.Identity.Web.Pages.Identity.Users { - public class IndexModel : AbpPageModel + public class IndexModel : IdentityPageModel { public void OnGet() { diff --git a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs index f8b42584ec..bc6a8cd27b 100644 --- a/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/Distributed_User_Change_Event_Tests.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.Identity public async Task Should_Register_Handler() { var options = GetRequiredService>().Value; - options.EtoMappings.ShouldContain(m => m.Key == typeof(IdentityUser) && m.Value == typeof(UserEto)); + options.EtoMappings.ShouldContain(m => m.Key == typeof(IdentityUser) && m.Value.EtoType == typeof(UserEto)); options.Handlers.ShouldContain(h => h == typeof(DistributedUserUpdateHandler)); }