This commit is contained in:
62
EveryThing/Pages/Projects/PrintPartItem.cshtml.cs
Normal file
62
EveryThing/Pages/Projects/PrintPartItem.cshtml.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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.Project;
|
||||
using EveryThing.Models.Transport;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")]
|
||||
public class PrintPartItem : PageModel
|
||||
{
|
||||
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public ProjectPartItem PartItem { get; set; }
|
||||
|
||||
public IList<ProjectPartItemOperation> Operations { get; set; }
|
||||
|
||||
public PrintPartItem(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int id)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
PartItem = await _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.ThenInclude(x => x.Company)
|
||||
.Include(x => x.Material)
|
||||
.Include(x => x.Item)
|
||||
.FirstOrDefaultAsync(x => x.IdProjectPartItem == id && x.ProjectPart.Project.Company.IdCompany == user.IdCompanyFk);
|
||||
|
||||
if (PartItem == null)
|
||||
return NotFound();
|
||||
|
||||
|
||||
Operations = await _context.ProjectPartItemOperations
|
||||
.Include(x => x.Operation)
|
||||
.Where(x => x.IdProjectPartItemFk == PartItem.IdProjectPartItem)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user