diff --git a/Areas/Inventory/Controllers/Admin/InventoryAdminController.cs b/Areas/Inventory/Controllers/Admin/InventoryAdminController.cs
new file mode 100644
index 0000000..962176d
--- /dev/null
+++ b/Areas/Inventory/Controllers/Admin/InventoryAdminController.cs
@@ -0,0 +1,13 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Controllers.Admin
+{
+ [Area("Inventory")]
+ public class InventoryAdminController : Controller
+ {
+ public IActionResult AdminDashboard()
+ {
+ return View();
+ }
+ }
+}
diff --git a/Controllers/Inventory/InventoryController.cs b/Areas/Inventory/Controllers/ItemController.cs
similarity index 84%
rename from Controllers/Inventory/InventoryController.cs
rename to Areas/Inventory/Controllers/ItemController.cs
index 74089e1..056d452 100644
--- a/Controllers/Inventory/InventoryController.cs
+++ b/Areas/Inventory/Controllers/ItemController.cs
@@ -1,9 +1,10 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-namespace PSTW_CentralSystem.Controllers.Inventory
+namespace PSTW_CentralSystem.Areas.Inventory.Controllers
{
- public class InventoryController : Controller
+ [Area("Inventory")]
+ public class ItemController : Controller
{
// GET: Inventory
public ActionResult Index()
@@ -11,6 +12,16 @@ namespace PSTW_CentralSystem.Controllers.Inventory
return View();
}
+ public IActionResult ItemRegistration()
+ {
+ return View();
+ }
+
+ public IActionResult ProductRegistration()
+ {
+ return View();
+ }
+
// GET: Inventory/Details/5
public ActionResult Details(int id)
{
diff --git a/Areas/Inventory/Controllers/MainController.cs b/Areas/Inventory/Controllers/MainController.cs
new file mode 100644
index 0000000..7fade01
--- /dev/null
+++ b/Areas/Inventory/Controllers/MainController.cs
@@ -0,0 +1,95 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Controllers
+{
+ [Area("Inventory")]
+
+ //[Route("Inventory/[controller]/[action]")]
+ public class MainController : Controller
+ {
+ // GET: Inventory
+ public ActionResult Index()
+ {
+ return View();
+ }
+
+ public IActionResult SupplierRegistration()
+ {
+ return View();
+ }
+ public IActionResult ManifacturerRegistration()
+ {
+ return View();
+ }
+
+ // GET: Inventory/Details/5
+ public ActionResult Details(int id)
+ {
+ return View();
+ }
+
+ // GET: Inventory/Create
+ public ActionResult Create()
+ {
+ return View();
+ }
+
+ // POST: Inventory/Create
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public ActionResult Create(IFormCollection collection)
+ {
+ try
+ {
+ return RedirectToAction(nameof(Index));
+ }
+ catch
+ {
+ return View();
+ }
+ }
+
+ // GET: Inventory/Edit/5
+ public ActionResult Edit(int id)
+ {
+ return View();
+ }
+
+ // POST: Inventory/Edit/5
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public ActionResult Edit(int id, IFormCollection collection)
+ {
+ try
+ {
+ return RedirectToAction(nameof(Index));
+ }
+ catch
+ {
+ return View();
+ }
+ }
+
+ // GET: Inventory/Delete/5
+ public ActionResult Delete(int id)
+ {
+ return View();
+ }
+
+ // POST: Inventory/Delete/5
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public ActionResult Delete(int id, IFormCollection collection)
+ {
+ try
+ {
+ return RedirectToAction(nameof(Index));
+ }
+ catch
+ {
+ return View();
+ }
+ }
+ }
+}
diff --git a/Areas/Inventory/Models/CompanyModel.cs b/Areas/Inventory/Models/CompanyModel.cs
new file mode 100644
index 0000000..617765a
--- /dev/null
+++ b/Areas/Inventory/Models/CompanyModel.cs
@@ -0,0 +1,11 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class CompanyModel
+ {
+ [Key]
+ public int CompanyId { get; set; }
+ public required string Name { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Models/DepartmentModel.cs b/Areas/Inventory/Models/DepartmentModel.cs
new file mode 100644
index 0000000..18e7fdf
--- /dev/null
+++ b/Areas/Inventory/Models/DepartmentModel.cs
@@ -0,0 +1,15 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class DepartmentModel
+ {
+ [Key]
+ public int DepartmentId { get; set; }
+ public required string Name { get; set; }
+ public required int CompanyId { get; set; }
+ [ForeignKey("CompanyId")]
+ public virtual required CompanyModel Company { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Models/ItemModel.cs b/Areas/Inventory/Models/ItemModel.cs
new file mode 100644
index 0000000..cd9b0c5
--- /dev/null
+++ b/Areas/Inventory/Models/ItemModel.cs
@@ -0,0 +1,33 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class ItemModel
+ {
+ [Key]
+ public required string ItemID { get; set; }
+ public required int CompanyId { get; set; }
+ public required int DepartmentId { get; set; }
+ public required int ProductId { get; set; }
+ public required string SerialNumber { get; set; }
+ public required int Quantity { get; set; }
+ public required string Supplier { get; set; }
+ public required DateTime PurchaseDate { get; set; }
+ public required string PONo { get; set; }
+ public required string Currency { get; set; }
+ public required float PriceInRM { get; set; }
+ public required float CurrencyRate { get; set; }
+ public required float ConvertPrice { get; set; }
+ public required DateTime DODate { get; set; }
+ public required int Warranty { get; set; }
+ public required DateTime EndWDate { get; set; }
+ public required DateTime InvoiceDate { get; set; }
+ [ForeignKey("CompanyId")]
+ public required virtual CompanyModel Company { get; set; }
+ [ForeignKey("DepartmentId")]
+ public required virtual DepartmentModel Department { get; set; }
+ [ForeignKey("ProductId")]
+ public required virtual ProductModel Product { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Models/ManufacturerModel.cs b/Areas/Inventory/Models/ManufacturerModel.cs
new file mode 100644
index 0000000..1e0c620
--- /dev/null
+++ b/Areas/Inventory/Models/ManufacturerModel.cs
@@ -0,0 +1,11 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class ManufacturerModel
+ {
+ [Key]
+ public int ManufacturerId { get; set; }
+ public required string ManufacturerName { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Models/ProductModel.cs b/Areas/Inventory/Models/ProductModel.cs
new file mode 100644
index 0000000..d2bf4ee
--- /dev/null
+++ b/Areas/Inventory/Models/ProductModel.cs
@@ -0,0 +1,20 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class ProductModel
+ {
+ [Key]
+ public int ProductId { get; set; }
+ public required string ProductName { get; set; }
+ public required string Manufacturer { get; set; }
+ public required string Category { get; set; }
+ public required string ModelNo { get; set; }
+ public required int QuantityProduct { get; set; }
+ public required string ImageProduct { get; set; }
+ public required int CompanyId { get; set; }
+ [ForeignKey("CompanyId")]
+ public required virtual CompanyModel Company { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Models/SupplierModel.cs b/Areas/Inventory/Models/SupplierModel.cs
new file mode 100644
index 0000000..4d46cf7
--- /dev/null
+++ b/Areas/Inventory/Models/SupplierModel.cs
@@ -0,0 +1,14 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace PSTW_CentralSystem.Areas.Inventory.Models
+{
+ public class SupplierModel
+ {
+ [Key]
+ public int SupplierId { get; set; }
+ public required string SupplierName { get; set; }
+ public required string SupplierGender { get; set; }
+ public required string SupplierEmail { get; set; }
+ public required string SupplierPhoneNo { get; set; }
+ }
+}
diff --git a/Areas/Inventory/Views/InventoryAdmin/AdminDashboard.cshtml b/Areas/Inventory/Views/InventoryAdmin/AdminDashboard.cshtml
new file mode 100644
index 0000000..6b260fa
--- /dev/null
+++ b/Areas/Inventory/Views/InventoryAdmin/AdminDashboard.cshtml
@@ -0,0 +1,12 @@
+@{
+ ViewData["Title"] = "PSTW Centralized System";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+
+@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
\ No newline at end of file
diff --git a/Areas/Inventory/Views/Item/ItemRegistration.cshtml b/Areas/Inventory/Views/Item/ItemRegistration.cshtml
new file mode 100644
index 0000000..c028496
--- /dev/null
+++ b/Areas/Inventory/Views/Item/ItemRegistration.cshtml
@@ -0,0 +1,595 @@
+
+@{
+ ViewData["Title"] = "Item Form";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+
+}
+
+
+
+@*Vue Js - POST & RESET*@
+
+
\ No newline at end of file
diff --git a/Areas/Inventory/Views/Item/ProductRegistration.cshtml b/Areas/Inventory/Views/Item/ProductRegistration.cshtml
new file mode 100644
index 0000000..18ea02b
--- /dev/null
+++ b/Areas/Inventory/Views/Item/ProductRegistration.cshtml
@@ -0,0 +1,291 @@
+@{
+ ViewData["Title"] = "Product Form";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
+
+
+
+
diff --git a/Areas/Inventory/Views/Item/Qr.cshtml b/Areas/Inventory/Views/Item/Qr.cshtml
new file mode 100644
index 0000000..b7e421d
--- /dev/null
+++ b/Areas/Inventory/Views/Item/Qr.cshtml
@@ -0,0 +1,107 @@
+@{
+ ViewData["Title"] = "QR & Barcode Scanner";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+
+
QR & Barcode Scanner
+
+
+
Scan Result:
+
{{ qrCodeResult }}
+
+
+
+
\ No newline at end of file
diff --git a/Areas/Inventory/Views/Main/Index.cshtml b/Areas/Inventory/Views/Main/Index.cshtml
new file mode 100644
index 0000000..8039624
--- /dev/null
+++ b/Areas/Inventory/Views/Main/Index.cshtml
@@ -0,0 +1,11 @@
+@{
+ ViewData["Title"] = "PSTW Centralized System";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+
diff --git a/Areas/Inventory/Views/Main/ManifacturerRegistration.cshtml b/Areas/Inventory/Views/Main/ManifacturerRegistration.cshtml
new file mode 100644
index 0000000..a8bbb7f
--- /dev/null
+++ b/Areas/Inventory/Views/Main/ManifacturerRegistration.cshtml
@@ -0,0 +1,208 @@
+@{
+ ViewData["Title"] = "Manufactures";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");
+
+@section Scripts {
+ @{
+ await Html.RenderPartialAsync("_ValidationScriptsPartial");
+ }
+
+}
+
diff --git a/Areas/Inventory/Views/Main/SupplierRegistration.cshtml b/Areas/Inventory/Views/Main/SupplierRegistration.cshtml
new file mode 100644
index 0000000..abec03e
--- /dev/null
+++ b/Areas/Inventory/Views/Main/SupplierRegistration.cshtml
@@ -0,0 +1,147 @@
+@{
+ ViewData["Title"] = "User Form";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+
+
+
\ No newline at end of file
diff --git a/Areas/Inventory/Views/_InventoryPartial.cshtml b/Areas/Inventory/Views/_InventoryPartial.cshtml
new file mode 100644
index 0000000..be28699
--- /dev/null
+++ b/Areas/Inventory/Views/_InventoryPartial.cshtml
@@ -0,0 +1,51 @@
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+
\ No newline at end of file
diff --git a/Controllers/API/AdminAPI.cs b/Controllers/API/AdminAPI.cs
index 1663a80..2f24be9 100644
--- a/Controllers/API/AdminAPI.cs
+++ b/Controllers/API/AdminAPI.cs
@@ -50,5 +50,34 @@ namespace PSTW_CentralSystem.Controllers.API
return Json(controllerAndMethodList);
}
+ [HttpPost("GetListClassAndMethodInformation")]
+ public async Task GetListClassAndMethodInformation()
+ {
+ var controllerAndMethodList = new List();
+
+ // Get the assembly containing the controllers
+ var assembly = Assembly.GetExecutingAssembly();
+
+ // Get all types in the assembly (controllers will typically be in the "Controllers" namespace)
+ //var controllerTypes = await Task.Run(() => assembly.GetTypes().Where(type => typeof(ControllerBase).IsAssignableFrom(type) && type.IsClass && type.Name.Contains("Controller") && type.Name != "AdminController") .ToList());
+ var controllerTypes = await Task.Run(() => assembly.GetTypes().Where(type => typeof(ControllerBase).IsAssignableFrom(type) && type.IsClass && !type.Name.Contains("API") && !type.Name.Contains("Admin")).ToList());
+
+ // Iterate over the controller types and get their methods
+ foreach (var controllerType in controllerTypes)
+ {
+ var methods = controllerType?.GetMethods(BindingFlags.Public | BindingFlags.Instance)
+ .Where(m => m.DeclaringType == controllerType) // Filter methods declared directly in the controller (ignoring inherited ones)
+ .Select(m => m.Name) // Get the method names
+ .ToList();
+
+ controllerAndMethodList.Add(new
+ {
+ Controller = controllerType?.Name,
+ Methods = methods
+ });
+ }
+ // Return the list as JSON
+ return Json(controllerAndMethodList);
+ }
}
}
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
new file mode 100644
index 0000000..3613946
--- /dev/null
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -0,0 +1,77 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using Mono.TextTemplating;
+using PSTW_CentralSystem.Areas.Inventory.Models;
+using PSTW_CentralSystem.DBContext;
+using PSTW_CentralSystem.Models;
+using System.Diagnostics;
+using System.Reflection;
+
+namespace PSTW_CentralSystem.Controllers.API.Inventory
+{
+ [ApiController]
+ [Route("[controller]")]
+
+ public class InvMainAPI : Controller
+ {
+ private readonly ILogger _logger;
+ private readonly AuthDBContext _authDbContext;
+
+ public InvMainAPI(ILogger logger, AuthDBContext authDbContext)
+ {
+ _logger = logger;
+ _authDbContext = authDbContext;
+ }
+
+ [HttpPost("ManufacturerList")]
+ public async Task ManufacturerList()
+ {
+ var manifacturerList = await _authDbContext.Manufacturers.ToListAsync();
+ return Json(manifacturerList);
+ }
+ [HttpPost("AddManufacturer")]
+ public async Task AddManufacturer([FromBody] ManufacturerModel manufacturer)
+ {
+ if (!ModelState.IsValid)
+ {
+ return BadRequest(ModelState);
+ }
+ if (manufacturer == null)
+ {
+ return NotFound("Manufacturer is null");
+ }
+
+ try
+ {
+ _authDbContext.Manufacturers.Add(new ManufacturerModel
+ {
+ ManufacturerName = manufacturer.ManufacturerName,
+ });
+ await _authDbContext.SaveChangesAsync();
+ var updatedList = await _authDbContext.Manufacturers.ToListAsync();
+ return Json(updatedList);
+ }
+ catch (Exception ex)
+ {
+ return BadRequest(ex.Message);
+ }
+ }
+
+ [HttpDelete("DeleteManufacturer/{id}")]
+ public async Task DeleteManufacturer(int id)
+ {
+ var manufacturer = await _authDbContext.Manufacturers.FindAsync(id);
+ if (manufacturer == null)
+ {
+ return NotFound(new { success = false, message = "Manufacturer not found" });
+ }
+
+ _authDbContext.Manufacturers.Remove(manufacturer);
+ await _authDbContext.SaveChangesAsync();
+
+ return Ok(new { success = true, message = "Manufacturer deleted successfully" });
+ }
+
+ }
+}
diff --git a/Controllers/API/ModuleAPI.cs b/Controllers/API/ModuleAPI.cs
index 48b2f6c..d18977a 100644
--- a/Controllers/API/ModuleAPI.cs
+++ b/Controllers/API/ModuleAPI.cs
@@ -111,6 +111,15 @@ namespace PSTW_CentralSystem.Controllers.API
return NotFound("Module is null");
}
+ var existName = await _authDbContext.ModuleSettings
+ .Where(x => x.ModuleName == module.ModuleName)
+ .FirstOrDefaultAsync();
+
+ if (existName != null)
+ {
+ return BadRequest("Name Module Already Exist");
+ }
+
try
{
_authDbContext.ModuleSettings.Add(module);
diff --git a/Controllers/AdminController.cs b/Controllers/AdminController.cs
index 4248a1b..16aab3e 100644
--- a/Controllers/AdminController.cs
+++ b/Controllers/AdminController.cs
@@ -43,7 +43,7 @@ namespace PSTW_CentralSystem.Controllers
return View(moduleSettings);
}
- public IActionResult AddModule()
+ public IActionResult CreateModule()
{
return View();
}
diff --git a/CustomPolicy/RoleModulePolicy.cs b/CustomPolicy/RoleModulePolicy.cs
index bd0cb1e..56526b9 100644
--- a/CustomPolicy/RoleModulePolicy.cs
+++ b/CustomPolicy/RoleModulePolicy.cs
@@ -18,8 +18,8 @@ namespace PSTW_CentralSystem.CustomPolicy
private readonly UserManager _userManager;
private readonly RoleManager _roleManager;
private readonly IHttpContextAccessor _httpContextAccessor;
- public RoleModuleHandler( AuthDBContext authDBContext, UserManager userManager, RoleManager roleManager, IHttpContextAccessor httpContextAccessor)
- {
+ public RoleModuleHandler(AuthDBContext authDBContext, UserManager userManager, RoleManager roleManager, IHttpContextAccessor httpContextAccessor)
+ {
_authDBContext = authDBContext;
_userManager = userManager;
_roleManager = roleManager;
@@ -39,7 +39,8 @@ namespace PSTW_CentralSystem.CustomPolicy
context.Succeed(requirement);
return;
}
- else {
+ else
+ {
checkModuleExistOrNot();
checkModuleHaveRoleOrNot();
}
@@ -65,7 +66,7 @@ namespace PSTW_CentralSystem.CustomPolicy
void checkModuleExistOrNot()
{
- if ( moduleName == "Admin")
+ if (moduleName == "Admin")
{
context.Fail();
return;
@@ -75,8 +76,8 @@ namespace PSTW_CentralSystem.CustomPolicy
context.Fail();
return;
}
- else
- {
+ else
+ {
checkModuleActiveOrNot();
}
}
@@ -98,7 +99,7 @@ namespace PSTW_CentralSystem.CustomPolicy
context.Succeed(requirement);
return;
}
- else if (currentUser != null && allowedUserTypes == "Registered User" )
+ else if (currentUser != null && allowedUserTypes == "Registered User")
{
checkMethodAndRole();
}
@@ -136,7 +137,7 @@ namespace PSTW_CentralSystem.CustomPolicy
}
}
else // No method is registered to allow all method to be accessed
- {
+ {
context.Succeed(requirement);
return;
}
diff --git a/DBContext/AuthDBContext.cs b/DBContext/AuthDBContext.cs
index 8b43cf9..c7a71cc 100644
--- a/DBContext/AuthDBContext.cs
+++ b/DBContext/AuthDBContext.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
+using PSTW_CentralSystem.Areas.Inventory.Models;
using PSTW_CentralSystem.Models;
using System.Text.Json;
@@ -71,5 +72,12 @@ namespace PSTW_CentralSystem.DBContext
public new DbSet Users { get; set; }
public new DbSet Roles { get; set; }
public DbSet ModuleSettings { get; set; }
+ public DbSet Companies { get; set; }
+ public DbSet Departments { get; set; }
+ public DbSet Manufacturers { get; set; }
+ public DbSet Items { get; set; }
+ public DbSet Products { get; set; }
+ public DbSet Suppliers { get; set; }
+
}
}
diff --git a/Views/Admin/AddModule.cshtml b/Views/Admin/AddModule.cshtml
deleted file mode 100644
index 1f2d012..0000000
--- a/Views/Admin/AddModule.cshtml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-@{
- ViewData["Title"] = "Add Module";
- Layout = "~/Views/Shared/_Layout.cshtml";
-}
-
-
-@section Scripts {
- @{
- await Html.RenderPartialAsync("_ValidationScriptsPartial");
- }
-
-
-}
diff --git a/Views/Admin/CreateModule.cshtml b/Views/Admin/CreateModule.cshtml
new file mode 100644
index 0000000..2cccaa4
--- /dev/null
+++ b/Views/Admin/CreateModule.cshtml
@@ -0,0 +1,177 @@
+
+@{
+ ViewData["Title"] = "Create Module";
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
+
+
+@section Scripts {
+ @{
+ await Html.RenderPartialAsync("_ValidationScriptsPartial");
+ }
+
+
+}
diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml
index 98c84bd..17beadf 100644
--- a/Views/Shared/_Layout.cshtml
+++ b/Views/Shared/_Layout.cshtml
@@ -29,6 +29,10 @@
+
+
+
+
@* *@
@@ -45,7 +49,7 @@
-