This commit is contained in:
2026-02-28 11:46:09 +01:00
parent e29fd39e39
commit 3d4bb077cc
3 changed files with 286 additions and 10 deletions

View 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();
}
}
}