razor pages virtualized

pull/3179/head
Ahmet Çotur 6 years ago
parent d2d5d79be4
commit a05961cf58

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

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

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

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

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