Skip to content

Commit

Permalink
Merge pull request #3579 from abpframework/maliming/IActionResult
Browse files Browse the repository at this point in the history
Use IActionResult as the return value of the page method in the module.
  • Loading branch information
hikalkan authored Apr 19, 2020
2 parents efbfdf8 + 21b3e1c commit cf44b8b
Show file tree
Hide file tree
Showing 34 changed files with 100 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ConsentModel(
_resourceStore = resourceStore;
}

public virtual async Task OnGet()
public virtual async Task<IActionResult> OnGet()
{
var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
if (request == null)
Expand Down Expand Up @@ -74,6 +74,8 @@ public virtual async Task OnGet()
{
ConsentInput.ApiScopes.Add(GetOfflineAccessScope(true));
}

return Page();
}

public virtual async Task<IActionResult> OnPost(string userDecision)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public virtual async Task<IActionResult> OnGetAsync()
return RedirectToPage("/Account/Login");
}

public virtual Task OnPostAsync()
public virtual Task<IActionResult> OnPostAsync()
{
return Task.CompletedTask;
return Task.FromResult<IActionResult>(Page());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Microsoft.AspNetCore.Mvc;

namespace Volo.Abp.Account.Web.Pages.Account
{
Expand All @@ -17,16 +18,18 @@ public ManageModel(IProfileAppService profileAppService)
ProfileAppService = profileAppService;
}

public virtual async Task OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
var user = await ProfileAppService.GetAsync();

PersonalSettingsInfoModel = ObjectMapper.Map<ProfileDto, PersonalSettingsInfoModel>(user);

return Page();
}

public virtual Task OnPostAsync()
public virtual Task<IActionResult> OnPostAsync()
{
return Task.CompletedTask;
return Task.FromResult<IActionResult>(Page());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public RegisterModel(IAccountAppService accountAppService)
AccountAppService = accountAppService;
}

public virtual async Task OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
await CheckSelfRegistrationAsync();

return Page();
}

public virtual async Task<IActionResult> OnPostAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public virtual async Task<IActionResult> OnGetAsync()
//);
}

public virtual Task OnPostAsync()
public virtual Task<IActionResult> OnPostAsync()
{
return Task.CompletedTask;
return Task.FromResult<IActionResult>(Page());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public CreateModel(IBlogAppService blogAppService, IAuthorizationService authori
_authorization = authorization;
}

public async Task<ActionResult> OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Create))
{
Expand All @@ -34,7 +34,7 @@ public async Task<ActionResult> OnGetAsync()
return Page();
}

public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
var blogDto = ObjectMapper.Map<BlogCreateModalView, CreateBlogDto>(Blog);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EditModel(IBlogAppService blogAppService, IAuthorizationService authoriza
_authorization = authorization;
}

public async Task<ActionResult> OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Update))
{
Expand All @@ -43,14 +43,16 @@ public async Task<ActionResult> OnGetAsync()
return Page();
}

public async Task OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
await _blogAppService.Update(Blog.Id, new UpdateBlogDto()
{
Name = Blog.Name,
ShortName = Blog.ShortName,
Description = Blog.Description
});

return Page();
}

public class BlogEditViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public IndexModel(IAuthorizationService authorization)
_authorization = authorization;
}

public async Task<ActionResult> OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Management))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public IndexModel(IBlogAppService blogAppService)
_blogAppService = blogAppService;
}

public async Task<IActionResult> OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
var result = await _blogAppService.GetListAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public DetailModel(IPostAppService postAppService, IBlogAppService blogAppServic
_commentAppService = commentAppService;
}

public async Task OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
await GetData();

return Page();
}

public async Task OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
var comment = await _commentAppService.CreateAsync(new CreateCommentDto()
{
Expand All @@ -63,6 +65,8 @@ public async Task OnPostAsync()
FocusCommentId = comment.Id;

await GetData();

return Page();
}

private async Task GetData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public EditModel(IPostAppService postAppService, IBlogAppService blogAppService,
_authorization = authorization;
}

public async Task<ActionResult> OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
if (!await _authorization.IsGrantedAsync(BloggingPermissions.Posts.Update))
{
Expand All @@ -47,7 +47,7 @@ public async Task<ActionResult> OnGetAsync()
return Page();
}

public async Task<ActionResult> OnPostAsync()
public virtual async Task<ActionResult> OnPostAsync()
{
var post = new UpdatePostDto
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public IndexModel(IPostAppService postAppService, IBlogAppService blogAppService
_tagAppService = tagAppService;
}

public async Task OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Posts = (await _postAppService.GetListByBlogIdAndTagName(Blog.Id, TagName)).Items;
PopularTags = (await _tagAppService.GetPopularTags(Blog.Id, new GetPopularTagsInput {ResultCount = 10, MinimumPostCount = 2}));

return Page();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public NewModel(IPostAppService postAppService, IBlogAppService blogAppService,
_blogOptions = blogOptions.Value;
}

public async Task<ActionResult> OnGetAsync()
public virtual async Task<ActionResult> OnGetAsync()
{
if (!await _authorization.IsGrantedAsync(BloggingPermissions.Posts.Create))
{
Expand All @@ -51,7 +51,7 @@ public async Task<ActionResult> OnGetAsync()
return Page();
}

public async Task<ActionResult> OnPost()
public virtual async Task<ActionResult> OnPost()
{
var blog = await _blogAppService.GetAsync(Post.BlogId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Volo.ClientSimulation.Pages.ClientSimulation
{
public class IndexModel : PageModel
{
public async Task OnGetAsync()
public virtual Task<IActionResult> OnGetAsync()
{

return Task.FromResult<IActionResult>(Page());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ public SimulationAreaModel(Simulation simulation)
Simulation = simulation;
}

public Task OnGetAsync()
public virtual Task<IActionResult> OnGetAsync()
{
Snapshot = Simulation.CreateSnapshot();
return Task.CompletedTask;
return Task.FromResult<IActionResult>(Page());
}

public async Task<IActionResult> OnPostStartAsync()
public virtual async Task<IActionResult> OnPostStartAsync()
{
Simulation.Start();
return new NoContentResult();
}

public async Task<IActionResult> OnPostStopAsync()
public virtual async Task<IActionResult> OnPostStopAsync()
{
Simulation.Stop();
return new NoContentResult();
Expand Down
2 changes: 1 addition & 1 deletion modules/docs/app/VoloDocs.Web/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public IndexModel(IOptions<DocsUiOptions> urlOptions, IProjectAppService project
_urlUiOptions = urlOptions.Value;
}

public async Task<IActionResult> OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
var projects = await _projectAppService.GetListAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CreateModel(IProjectAdminAppService projectAppService)
_projectAppService = projectAppService;
}

public async Task<ActionResult> OnGetAsync(string source)
public virtual async Task<ActionResult> OnGetAsync(string source)
{
if (source != null && source.ToLowerInvariant() == "github")
{
Expand All @@ -42,7 +42,7 @@ public async Task<ActionResult> OnGetAsync(string source)
}
}

public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
if (GithubProject != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EditModel(IProjectAdminAppService projectAppService)
_projectAppService = projectAppService;
}

public async Task<ActionResult> OnGetAsync(Guid id)
public virtual async Task<ActionResult> OnGetAsync(Guid id)
{
var project = await _projectAppService.GetAsync(id);

Expand All @@ -42,7 +42,7 @@ public async Task<ActionResult> OnGetAsync(Guid id)
throw new BusinessException("UnknowDocumentSourceExceptionMessage");
}

public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
if (GithubProject != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;

namespace Volo.Docs.Admin.Pages.Docs.Admin.Projects
{
[Authorize(DocsAdminPermissions.Projects.Default)]
public class IndexModel : DocsAdminPageModel
{
public void OnGet()
public virtual Task<IActionResult> OnGet()
{
return Task.FromResult<IActionResult>(Page());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public PullModel(IProjectAdminAppService projectAppService,
_documentAppService = documentAppService;
}

public async Task<ActionResult> OnGetAsync(Guid id)
public virtual async Task<ActionResult> OnGetAsync(Guid id)
{
var project = await _projectAppService.GetAsync(id);

Expand All @@ -36,7 +36,7 @@ public async Task<ActionResult> OnGetAsync(Guid id)
return Page();
}

public async Task<IActionResult> OnPostAsync()
public virtual async Task<IActionResult> OnPostAsync()
{
if (PullDocument.All)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public IndexModel(
_uiOptions = urlOptions.Value;
}

public async Task<IActionResult> OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
DocumentsUrlPrefix = _uiOptions.RoutePrefix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public IndexModel(
_uiOptions = options.Value;
}

public async Task<IActionResult> OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SearchModel(IProjectAppService projectAppService,

public List<DocumentSearchOutput> SearchOutputs { get; set; } = new List<DocumentSearchOutput>();

public async Task<IActionResult> OnGetAsync(string keyword)
public virtual async Task<IActionResult> OnGetAsync(string keyword)
{
if (!await _documentAppService.FullSearchEnabledAsync())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public CreateModalModel(IIdentityRoleAppService identityRoleAppService)
IdentityRoleAppService = identityRoleAppService;
}

public virtual Task OnGetAsync()
public virtual Task<IActionResult> OnGetAsync()
{
return Task.CompletedTask;
return Task.FromResult<IActionResult>(Page());
}

public virtual async Task<IActionResult> OnPostAsync()
Expand Down
Loading

0 comments on commit cf44b8b

Please sign in to comment.