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.Invoice; using EveryThing.Models.Transport; using DocumentFormat.OpenXml.Wordprocessing; using System.ComponentModel.DataAnnotations; namespace EveryThing.Pages.Projects { [Authorize(Roles = "Administrator,InvoicingUser,ProjecThingUser")] public class PrintProjectPartPathsModel : PageModel { private readonly ApplicationDbContext _context; private readonly UserManager _userManager; public Models.Project.Project Project { get; set; } public IList Items { get; set; } public string ProjectNumber { get; set; } public PrintProjectPartPathsModel(ApplicationDbContext context, UserManager userManager) { _context = context; _userManager = userManager; } public async Task OnGetAsync(int id) { var user = _userManager.GetUserAsync(User).Result; var projectPart = _context .ProjectParts.Include(x => x.Project) .ThenInclude(x => x.Company) .FirstOrDefault(); if (projectPart == null) return NotFound(); Project = projectPart.Project; ProjectNumber = projectPart.ProjectPartNumberFormatted; Items = await _context.ProjectPartItems .Include(x => x.ProjectPart) .ThenInclude(x => x.Project) .Include(x => x.Item) .Where(x => x.IdProjectPartFk == id) .ToListAsync(); return Page(); } } }