56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using EveryThing.Data;
|
|
using EveryThing.Models;
|
|
using EveryThing.Models.Transport;
|
|
|
|
namespace EveryThing.Pages.TransportLoadingOrder
|
|
{
|
|
[Authorize(Roles = "Administrator,TransportThingUser")]
|
|
public class PrintModel : PageModel
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
private readonly UserManager<IdentityApplicationUser> _userManager;
|
|
|
|
public Models.Transport.TransportLoadingOrder TransportLoadingOrder { get; set; }
|
|
public IList<TransportLoadingOrderLoadUnload> TransportLoadingOrderLoadUnloadList { get; set; }
|
|
|
|
public PrintModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
|
{
|
|
_context = context;
|
|
_userManager = userManager;
|
|
}
|
|
|
|
public async Task<IActionResult> OnGetAsync(int id)
|
|
{
|
|
var user = _userManager.GetUserAsync(User).Result;
|
|
|
|
TransportLoadingOrder = await _context.TransportLoadingOrders
|
|
.Include(x => x.Company)
|
|
.Include(x => x.Company.Country)
|
|
.Include(x => x.Partner)
|
|
.Include(x => x.Partner.Country)
|
|
.FirstOrDefaultAsync(x => x.IdTransportLoadingOrder == id && x.IdCompanyFk == user.IdCompanyFk);
|
|
|
|
if (TransportLoadingOrder != null)
|
|
{
|
|
TransportLoadingOrderLoadUnloadList = await _context.TransportLoadingOrderLoadUnloads
|
|
.Where(x => x.IdTransportLoadingOrderFk == TransportLoadingOrder.IdTransportLoadingOrder)
|
|
.Include(x => x.Loading)
|
|
.Include(x => x.Unloading).ToListAsync();
|
|
|
|
return Page();
|
|
}
|
|
|
|
return NotFound();
|
|
}
|
|
}
|
|
}
|