From 05a07ca5ea462c3eeb84245bffabfa50da462bd6 Mon Sep 17 00:00:00 2001 From: Mohd Ariff Date: Tue, 26 Nov 2024 12:33:06 +0800 Subject: [PATCH] Update --- .../Views/Item/ProductRegistration.cshtml | 67 ++++++------------- Controllers/API/AdminAPI.cs | 28 ++++++++ 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Areas/Inventory/Views/Item/ProductRegistration.cshtml b/Areas/Inventory/Views/Item/ProductRegistration.cshtml index 18ea02b..ef59cd4 100644 --- a/Areas/Inventory/Views/Item/ProductRegistration.cshtml +++ b/Areas/Inventory/Views/Item/ProductRegistration.cshtml @@ -4,15 +4,17 @@ } @await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); -
+
-

REGISTRATION PRODUCT

-
+
+

REGISTRATION PRODUCT

+
+
@* Product Name *@ @@ -27,23 +29,11 @@
-
@@ -52,30 +42,16 @@
-
-
@* Model No Coding *@ @@ -126,8 +102,10 @@ el: '#registerProduct', data: { productName: null, - manufacturer: null, - category: null, + manufacturer: '', + manufacturers: null, + category: '', + categories: ["Item", "Part", "Disposable"], modelNo: null, quantityProduct: null, imageProduct: null, @@ -273,12 +251,7 @@ console.log(data); if (data != null && data.length > 0) { - this.manufacturer = data; - } - if (!this.manufacturerDatatable) { - this.initiateTable(); - } else { - this.fillTable(data); + this.manufacturers = data; } }) .catch(error => { diff --git a/Controllers/API/AdminAPI.cs b/Controllers/API/AdminAPI.cs index 6758fb4..40fbaa5 100644 --- a/Controllers/API/AdminAPI.cs +++ b/Controllers/API/AdminAPI.cs @@ -45,6 +45,34 @@ namespace PSTW_CentralSystem.Controllers.API // Return the list as JSON 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); + } } }