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 _userManager; public ProjectPartItem PartItem { get; set; } public IList Operations { get; set; } public PrintPartItem(ApplicationDbContext context, UserManager userManager) { _context = context; _userManager = userManager; } public async Task 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(); } } }