Added AbpPageModel.

pull/179/head
Halil İbrahim Kalkan 8 years ago
parent 74b68cdd55
commit a0ed546173

@ -51,7 +51,12 @@ namespace AbpDesk.Web.Mvc
//services.Configure<RemoteServiceOptions>(configuration); //Needed when we use Volo.Abp.Identity.HttpApi.Client
services.AddMvc().AddViewLocalization(); //TODO: Move to AbpAspNetCoreMvcModule!
services.AddMvc() //TODO: Move to AbpAspNetCoreMvcModule!
.AddViewLocalization()
.AddRazorPagesOptions(options =>
{
options.Conventions.AuthorizeFolder("/App");
});
services.AddAssemblyOf<AbpDeskWebMvcModule>();

@ -1,5 +1,6 @@
@page
@model AbpDesk.Web.Mvc.Pages.Tickets.IndexModel
@using AbpDesk.Web.Mvc.Pages.App.Tickets
@model AbpDesk.Web.Mvc.Pages.App.Tickets.IndexModel
@section styles
{

@ -2,11 +2,11 @@
using System.Threading.Tasks;
using AbpDesk.Tickets;
using AbpDesk.Tickets.Dtos;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Volo.Abp.AspNetCore.Mvc.RazorPages;
namespace AbpDesk.Web.Mvc.Pages.Tickets
namespace AbpDesk.Web.Mvc.Pages.App.Tickets
{
public class IndexModel : PageModel
public class IndexModel : AbpPageModel
{
public IReadOnlyList<TicketDto> Tickets { get; set; }
@ -19,6 +19,7 @@ namespace AbpDesk.Web.Mvc.Pages.Tickets
public async Task OnGetAsync(GetAllTicketsInput input)
{
var uow = CurrentUnitOfWork;
var result = await _ticketAppService.GetAll(input);
Tickets = result.Items;
}

@ -0,0 +1,26 @@
using System;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
namespace Volo.Abp.AspNetCore.Mvc.RazorPages
{
public abstract class AbpPageModel : PageModel
{
public IUnitOfWorkManager UnitOfWorkManager { get; set; }
public IObjectMapper ObjectMapper { get; set; }
public IGuidGenerator GuidGenerator { get; set; }
public ILoggerFactory LoggerFactory { get; set; }
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current;
protected ILogger Logger => _lazyLogger.Value;
private Lazy<ILogger> _lazyLogger => new Lazy<ILogger>(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
}
}

@ -45,6 +45,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
var options = CreateOptions(context, unitOfWorkAttr);
//Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware
if (_unitOfWorkManager.TryBeginReserved(UnitOfWorkReservationName, options))
{
var result = await next();
@ -56,6 +57,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
return;
}
//Begin a new, independent unit of work
using (var uow = _unitOfWorkManager.Begin(options))
{
var result = await next();

Loading…
Cancel
Save