2025-05-22 13:35:27 -07:00

75 lines
1.7 KiB
C#

#if !NET8
using System.Web;
using System.Web.Mvc;
#endif
#if NET8
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
#endif
using Fab2ApprovalSystem.DMO;
using Fab2ApprovalSystem.Misc;
#if !NET8
using System;
using System.Collections.Generic;
using System.Linq;
using Fab2ApprovalSystem.Models;
#endif
namespace Fab2ApprovalSystem.Controllers;
[Authorize]
#if !NET8
[SessionExpireFilter]
#endif
#if NET8
[Route("[controller]")]
#endif
public class ManagerController : Controller {
private readonly UserAccountDMO userDMO = new();
private readonly AdminDMO adminDMO = new();
private readonly TrainingDMO trainingDMO = new();
private readonly LotDispositionDMO ldDMO = new();
public ActionResult Index() {
if (GlobalVars.IsManager(GetSession())) {
var model = userDMO.GetAllUsers();
ViewBag.AllActiveUsers = userDMO.GetAllActiveUsers();
return View(model);
} else
return Content("Not Autthorized");
}
#if !NET8
private System.Web.HttpSessionStateBase GetSession() =>
Session;
private JsonResult GetJsonResult(object? data) =>
Json(data, JsonRequestBehavior.AllowGet);
private bool IsAjaxRequest() =>
Request.IsAjaxRequest();
#endif
#if NET8
private Microsoft.AspNetCore.Http.ISession GetSession() =>
HttpContext.Session;
private JsonResult GetJsonResult(object? data) =>
Json(data);
private bool IsAjaxRequest() =>
Request.Headers.TryGetValue("X-Requested-With", out Microsoft.Extensions.Primitives.StringValues strings) && strings[0] == "XMLHttpRequest";
#endif
private string GetUserIdentityName() =>
@User.Identity.Name;
}