rename to projecting

This commit is contained in:
2026-06-16 18:04:55 +02:00
parent da7b320032
commit bcde4178df
14778 changed files with 3658 additions and 3642 deletions

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using ProjecThing.Data;
using ProjecThing.Models;
using ProjecThing.Models.Project;
using Microsoft.AspNetCore.Authorization;
namespace ProjecThing.Pages.Projects
{
[Authorize(Roles = "Administrator,ProjecThingUser")]
public class CreateModel : PageModel
{
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityApplicationUser> _userManager;
private readonly SignInManager<IdentityApplicationUser> _loginManager;
private readonly RoleManager<IdentityApplicationRole> _roleManager;
public CreateModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> loginManager, RoleManager<IdentityApplicationRole> roleManager)
{
_context = context;
_userManager = userManager;
_loginManager = loginManager;
_roleManager = roleManager;
}
public IActionResult OnGet()
{
var user = _userManager.GetUserAsync(User).Result;
ViewData["IdPartnerFk"] = new SelectList(_context.CodeTablePartners.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active), "IdPartner", "Title");
return Page();
}
[BindProperty]
public Models.Project.Project Project { get; set; }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = _userManager.GetUserAsync(User).Result;
Project.IdCompanyFk = user.IdCompanyFk;
Project.Status = ProjectStatus.Opened;
Project.ProjectYear = DateTime.Now.Year;
var items = _context.Projects
.Where(x => x.IdCompanyFk == user.IdCompanyFk
&& x.ProjectYear == Project.ProjectYear).ToList();
Project.ProjectNumber = items.Count <= 0 ? 1 : items.Max(x => x.ProjectNumber) + 1;
_context.Projects.Add(Project);
await _context.SaveChangesAsync();
return RedirectToPage("./Edit", new { id = Project.IdProject });
}
}
}