Created ServiceBasedPageModelActivatorProvider.

pull/179/head
Halil İbrahim Kalkan 8 years ago
parent a0ed546173
commit 0f70f64134

@ -19,7 +19,6 @@ namespace AbpDesk.Web.Mvc.Pages.App.Tickets
public async Task OnGetAsync(GetAllTicketsInput input)
{
var uow = CurrentUnitOfWork;
var result = await _ticketAppService.GetAll(input);
Tickets = result.Items;
}

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Volo.Abp.AspNetCore.Mvc.RazorPages;
namespace AbpDesk.Web.Mvc.Pages
{
public class IndexModel : PageModel
public class IndexModel : AbpPageModel
{
public void OnGet()
{

@ -23,4 +23,8 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Volo\Abp\AspNetCore\Mvc\RazorPages\NewFolder\" />
</ItemGroup>
</Project>

@ -2,13 +2,14 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
namespace Volo.Abp.AspNetCore.Mvc.RazorPages
{
public abstract class AbpPageModel : PageModel
public abstract class AbpPageModel : PageModel, ITransientDependency //TODO: Register PageModels by convention, instead of using ITransientDependency
{
public IUnitOfWorkManager UnitOfWorkManager { get; set; }

@ -0,0 +1,23 @@
using System;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.RazorPages
{
[Dependency(ReplaceServices = true)]
public class ServiceBasedPageModelActivatorProvider : IPageModelActivatorProvider, ITransientDependency
{
public Func<PageContext, object> CreateActivator([NotNull] CompiledPageActionDescriptor descriptor)
{
Check.NotNull(descriptor, nameof(descriptor));
return context => context.HttpContext.RequestServices.GetRequiredService(descriptor.ModelTypeInfo);
}
public Action<PageContext, object> CreateReleaser([NotNull] CompiledPageActionDescriptor descriptor)
{
return null;
}
}
}

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Volo.Abp.AspNetCore.Mvc.RazorPages;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
public class IndexModel : PageModel
public class IndexModel : AbpPageModel
{
public void OnGet()
{

Loading…
Cancel
Save