From a05961cf5882a221760aa712e0b768fb4700228d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Wed, 18 Mar 2020 12:39:47 +0300 Subject: [PATCH] razor pages virtualized --- .../Identity/Roles/CreateModal.cshtml.cs | 13 ++++++++---- .../Pages/Identity/Roles/EditModal.cshtml.cs | 12 +++++------ .../Pages/Identity/Roles/Index.cshtml.cs | 10 +++++++++- .../Identity/Users/CreateModal.cshtml.cs | 16 +++++++-------- .../Pages/Identity/Users/EditModal.cshtml.cs | 20 +++++++++---------- .../Pages/Identity/Users/Index.cshtml.cs | 11 ++++++++-- 6 files changed, 51 insertions(+), 31 deletions(-) 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 b3fdad3a95..6d022c7048 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 @@ -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 OnPostAsync() + public virtual Task OnGetAsync() + { + return Task.CompletedTask; + } + + public virtual async Task OnPostAsync() { ValidateModel(); var input = ObjectMapper.Map(Role); - await _identityRoleAppService.CreateAsync(input); + await IdentityRoleAppService.CreateAsync(input); return NoContent(); } 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 8416e171b0..69305d243c 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 @@ -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( - await _identityRoleAppService.GetAsync(id) + await IdentityRoleAppService.GetAsync(id) ); } - public async Task OnPostAsync() + public virtual async Task OnPostAsync() { ValidateModel(); var input = ObjectMapper.Map(Role); - await _identityRoleAppService.UpdateAsync(Role.Id, input); + await IdentityRoleAppService.UpdateAsync(Role.Id, input); return NoContent(); } 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 db83e82003..0fab86d195 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,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; } } } \ No newline at end of file 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 6c1ac1ff72..f480ee925f 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 @@ -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, AssignedRoleViewModel[]>(roleDtoList); @@ -39,14 +39,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users } } - public async Task OnPostAsync() + public virtual async Task OnPostAsync() { ValidateModel(); var input = ObjectMapper.Map(UserInfo); input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray(); - await _identityUserAppService.CreateAsync(input); + await IdentityUserAppService.CreateAsync(input); return NoContent(); } 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 98a32fd1bd..df676ecaf4 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 @@ -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(await _identityUserAppService.GetAsync(id)); + UserInfo = ObjectMapper.Map(await IdentityUserAppService.GetAsync(id)); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>((await _identityRoleAppService.GetAllListAsync()).Items); + Roles = ObjectMapper.Map, 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 OnPostAsync() + public virtual async Task OnPostAsync() { ValidateModel(); var input = ObjectMapper.Map(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(); } 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 c8d4e84e82..d1382c59b6 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,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; } } }