78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
|
|
namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
|
{
|
|
[Area("Inventory")]
|
|
//[Authorize(Policy = "RoleModulePolicy")]
|
|
public class MainController : Controller
|
|
{
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
public MainController(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
_httpContextAccessor = httpContextAccessor;
|
|
}
|
|
public string GetCurrentUserId()
|
|
{
|
|
var user = _httpContextAccessor.HttpContext?.User;
|
|
|
|
if (user == null)
|
|
{
|
|
return null!;
|
|
}
|
|
|
|
return user.FindFirstValue(ClaimTypes.NameIdentifier) ?? null!; // Returns the user ID
|
|
}
|
|
|
|
// GET: Inventory
|
|
public ActionResult Index()
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
public IActionResult SupplierRegistration()
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
public IActionResult ManifacturerRegistration()
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
// GET: Inventory/Details/5
|
|
public ActionResult Details(int id)
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
// GET: Inventory/Create
|
|
public ActionResult Create()
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
// GET: Inventory/Edit/5
|
|
public ActionResult Edit(int id)
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
// GET: Inventory/Delete/5
|
|
public ActionResult Delete(int id)
|
|
{
|
|
var userId = GetCurrentUserId();
|
|
return View(userId);
|
|
}
|
|
|
|
}
|
|
}
|