Browse Source

Merge pull request #3179 from abpframework/Cotur-Virtualization-Identity

Make Identity module razor pages easily overridable by inheritance
pull/3182/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
55827d443d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs
  2. 12
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs
  3. 10
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs
  4. 16
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
  5. 20
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  6. 11
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs

13
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/CreateModal.cshtml.cs

@ -9,19 +9,24 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
[BindProperty]
public RoleInfoModel Role { get; set; }
private readonly IIdentityRoleAppService _identityRoleAppService;
protected IIdentityRoleAppService IdentityRoleAppService { get; }
public CreateModalModel(IIdentityRoleAppService identityRoleAppService)
{
_identityRoleAppService = identityRoleAppService;
IdentityRoleAppService = identityRoleAppService;
}
public async Task<IActionResult> OnPostAsync()
public virtual Task OnGetAsync()
{
return Task.CompletedTask;
}
public virtual async Task<IActionResult> OnPostAsync()
{
ValidateModel();
var input = ObjectMapper.Map<RoleInfoModel, IdentityRoleCreateDto>(Role);
await _identityRoleAppService.CreateAsync(input);
await IdentityRoleAppService.CreateAsync(input);
return NoContent();
}

12
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/EditModal.cshtml.cs

@ -11,26 +11,26 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
[BindProperty]
public RoleInfoModel Role { get; set; }
private readonly IIdentityRoleAppService _identityRoleAppService;
protected IIdentityRoleAppService IdentityRoleAppService { get; }
public EditModalModel(IIdentityRoleAppService identityRoleAppService)
{
_identityRoleAppService = identityRoleAppService;
IdentityRoleAppService = identityRoleAppService;
}
public async Task OnGetAsync(Guid id)
public virtual async Task OnGetAsync(Guid id)
{
Role = ObjectMapper.Map<IdentityRoleDto, RoleInfoModel>(
await _identityRoleAppService.GetAsync(id)
await IdentityRoleAppService.GetAsync(id)
);
}
public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
ValidateModel();
var input = ObjectMapper.Map<RoleInfoModel, IdentityRoleUpdateDto>(Role);
await _identityRoleAppService.UpdateAsync(Role.Id, input);
await IdentityRoleAppService.UpdateAsync(Role.Id, input);
return NoContent();
}

10
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml.cs

@ -1,9 +1,17 @@
using System.Threading.Tasks;
namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
{
public class IndexModel : IdentityPageModel
{
public void OnGet()
public virtual Task OnGetAsync()
{
return Task.CompletedTask;
}
public virtual Task OnPostAsync()
{
return Task.CompletedTask;
}
}
}

16
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs

@ -16,20 +16,20 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
[BindProperty]
public AssignedRoleViewModel[] Roles { get; set; }
private readonly IIdentityUserAppService _identityUserAppService;
private readonly IIdentityRoleAppService _identityRoleAppService;
protected IIdentityUserAppService IdentityUserAppService { get; }
protected IIdentityRoleAppService IdentityRoleAppService { get; }
public CreateModalModel(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService)
{
_identityUserAppService = identityUserAppService;
_identityRoleAppService = identityRoleAppService;
IdentityUserAppService = identityUserAppService;
IdentityRoleAppService = identityRoleAppService;
}
public async Task OnGetAsync()
public virtual async Task OnGetAsync()
{
UserInfo = new UserInfoViewModel();
var roleDtoList = (await _identityRoleAppService.GetAllListAsync()).Items;
var roleDtoList = (await IdentityRoleAppService.GetAllListAsync()).Items;
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList);
@ -39,14 +39,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
}
}
public async Task<NoContentResult> OnPostAsync()
public virtual async Task<NoContentResult> OnPostAsync()
{
ValidateModel();
var input = ObjectMapper.Map<UserInfoViewModel, IdentityUserCreateDto>(UserInfo);
input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray();
await _identityUserAppService.CreateAsync(input);
await IdentityUserAppService.CreateAsync(input);
return NoContent();
}

20
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs

@ -18,22 +18,22 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
[BindProperty]
public AssignedRoleViewModel[] Roles { get; set; }
private readonly IIdentityUserAppService _identityUserAppService;
private readonly IIdentityRoleAppService _identityRoleAppService;
protected IIdentityUserAppService IdentityUserAppService { get; }
protected IIdentityRoleAppService IdentityRoleAppService { get; }
public EditModalModel(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService)
{
_identityUserAppService = identityUserAppService;
_identityRoleAppService = identityRoleAppService;
IdentityUserAppService = identityUserAppService;
IdentityRoleAppService = identityRoleAppService;
}
public async Task OnGetAsync(Guid id)
public virtual async Task OnGetAsync(Guid id)
{
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id));
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await IdentityUserAppService.GetAsync(id));
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>((await _identityRoleAppService.GetAllListAsync()).Items);
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>((await IdentityRoleAppService.GetAllListAsync()).Items);
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();
var userRoleNames = (await IdentityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();
foreach (var role in Roles)
{
if (userRoleNames.Contains(role.Name))
@ -43,13 +43,13 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
}
}
public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
ValidateModel();
var input = ObjectMapper.Map<UserInfoViewModel, IdentityUserUpdateDto>(UserInfo);
input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray();
await _identityUserAppService.UpdateAsync(UserInfo.Id, input);
await IdentityUserAppService.UpdateAsync(UserInfo.Id, input);
return NoContent();
}

11
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml.cs

@ -1,10 +1,17 @@
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
using System.Threading.Tasks;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
public class IndexModel : IdentityPageModel
{
public void OnGet()
public virtual Task OnGetAsync()
{
return Task.CompletedTask;
}
public virtual Task OnPostAsync()
{
return Task.CompletedTask;
}
}
}

Loading…
Cancel
Save