#1845 Use Contextualized mapper on the identity module.

pull/1716/head^2
Halil İbrahim Kalkan 6 years ago
parent 0aa89831d5
commit 7f6dd3c83e

@ -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<AbpIdentityApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpIdentityApplicationModuleAutoMapperProfile>(validate: true);

@ -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);
}
}
}

@ -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;

@ -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
{

@ -283,7 +283,7 @@ namespace Volo.Abp.Identity
UserEto IMapTo<UserEto>.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
{

@ -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<AbpIdentityWebModule>("Volo.Abp.Identity.Web");
});
context.Services.AddAutoMapperObjectMapper<AbpIdentityWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpIdentityWebAutoMapperProfile>(validate: true);

@ -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);
}
}
}

@ -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; }

@ -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; }

@ -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()
{

@ -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; }

@ -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; }

@ -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()
{

@ -31,7 +31,7 @@ namespace Volo.Abp.Identity
public async Task Should_Register_Handler()
{
var options = GetRequiredService<IOptions<DistributedEventBusOptions>>().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));
}

Loading…
Cancel
Save