diff --git a/Areas/Inventory/Controllers/Admin/InventoryMasterController.cs b/Areas/Inventory/Controllers/Admin/InventoryMasterController.cs index 300725f..89b0e99 100644 --- a/Areas/Inventory/Controllers/Admin/InventoryMasterController.cs +++ b/Areas/Inventory/Controllers/Admin/InventoryMasterController.cs @@ -22,11 +22,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers.Admin return View(); } - public IActionResult ItemRequest() - { - return View(); - } - public IActionResult ItemRequestAdmin() + public IActionResult ItemRequestMaster() { return View(); } diff --git a/Areas/Inventory/Controllers/ItemMovementController.cs b/Areas/Inventory/Controllers/ItemMovementController.cs index e12df88..fe1eb52 100644 --- a/Areas/Inventory/Controllers/ItemMovementController.cs +++ b/Areas/Inventory/Controllers/ItemMovementController.cs @@ -7,7 +7,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers { [Area("Inventory")] - //[Authorize(Policy = "RoleModulePolicy")] + [Authorize(Policy = "RoleModulePolicy")] public class ItemMovementController : Controller { // GET: Inventory @@ -20,6 +20,16 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers return View(); } + public IActionResult ItemRequest() + { + return View(); + } + + public IActionResult UserDashboard() + { + return View(); + } + [Authorize] [HttpPost("/i/{id}")] public IActionResult ItemRecognization(string id, [FromBody] ItemModel item) diff --git a/Areas/Inventory/Models/RequestModel.cs b/Areas/Inventory/Models/RequestModel.cs index 58e9fd4..d773fd6 100644 --- a/Areas/Inventory/Models/RequestModel.cs +++ b/Areas/Inventory/Models/RequestModel.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace PSTW_CentralSystem.Areas.Inventory.Models { + [Table("request")] public class RequestModel { [Key] @@ -20,9 +21,9 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models public string? remark { get; set; } public string? status { get; set; } public DateTime requestDate { get; set; } - public DateTime approvalDate { get; set; } + public DateTime? approvalDate { get; set; } public int RequestQuantity { get; set; } - public byte[]? Document { get; set; } + public string? Document { get; set; } } } diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRequest.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRequest.cshtml deleted file mode 100644 index d769aa7..0000000 --- a/Areas/Inventory/Views/InventoryMaster/ItemRequest.cshtml +++ /dev/null @@ -1,785 +0,0 @@ - -@{ - ViewData["Title"] = "Product Request"; - Layout = "~/Views/Shared/_Layout.cshtml"; -} -@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); -
-
-
- -
-
- @*
-
- Loading... -
-
*@ -
-
-
- - -@section Scripts { -@{ - await Html.RenderPartialAsync("_ValidationScriptsPartial"); -} - -} \ No newline at end of file diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml index dd974c3..5f28270 100644 --- a/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml +++ b/Areas/Inventory/Views/InventoryMaster/ItemRequestMaster.cshtml @@ -1,783 +1 @@ - -@{ - ViewData["Title"] = "Product Request"; - Layout = "~/Views/Shared/_Layout.cshtml"; -} -@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); -
-
-
- -
-
- @*
-
- Loading... -
-
*@ -
-
-
- - -@section Scripts { -@{ - await Html.RenderPartialAsync("_ValidationScriptsPartial"); -} - -} \ No newline at end of file + \ No newline at end of file diff --git a/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml b/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml new file mode 100644 index 0000000..a07e6c2 --- /dev/null +++ b/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml @@ -0,0 +1,495 @@ + +@{ + ViewData["Title"] = "Product Request"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} +@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml"); +
+ + + + + +
+
+ +
+
+ @*
+
+ Loading... +
+
*@ +
+
+
+ + +@section Scripts { +@{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); +} + +} \ No newline at end of file diff --git a/Areas/Inventory/Views/ItemMovement/UserDashboard.cshtml b/Areas/Inventory/Views/ItemMovement/UserDashboard.cshtml new file mode 100644 index 0000000..f130caa --- /dev/null +++ b/Areas/Inventory/Views/ItemMovement/UserDashboard.cshtml @@ -0,0 +1,90 @@ +@{ + ViewData["Title"] = "Dashboard"; + Layout = "~/Views/Shared/_Layout.cshtml"; +} +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +
+
+
+

Inventory User Dashboard

+

Store: {{ currentUserCompanyDept.departmentName }}

+
+
+ @await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartialUser.cshtml"); +
+@section Scripts { +@{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); +} + +} \ No newline at end of file diff --git a/Areas/Inventory/Views/_InventoryPartial.cshtml b/Areas/Inventory/Views/_InventoryPartial.cshtml index c2e2dd1..52b5bf1 100644 --- a/Areas/Inventory/Views/_InventoryPartial.cshtml +++ b/Areas/Inventory/Views/_InventoryPartial.cshtml @@ -76,7 +76,7 @@
- +

diff --git a/Areas/Inventory/Views/_InventoryPartialUser.cshtml b/Areas/Inventory/Views/_InventoryPartialUser.cshtml new file mode 100644 index 0000000..08ceac0 --- /dev/null +++ b/Areas/Inventory/Views/_InventoryPartialUser.cshtml @@ -0,0 +1,28 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + \ No newline at end of file diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index 42c4781..3db2258 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -730,10 +730,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory #endregion ItemMovement #region ItemRequestUser - [HttpPost("AddRequest")] - public async Task AddRequest([FromBody] RequestModel request, [FromQuery] int UserId) - + public async Task AddRequest([FromBody] RequestModel request) { if (!ModelState.IsValid) { @@ -745,9 +743,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory _centralDbContext.Requests.Add(request); await _centralDbContext.SaveChangesAsync(); - //ini akan paparkan user punya table sahaja. - - var updatedList = await _centralDbContext.Requests.Where(r => r.UserId == UserId).ToListAsync(); + var updatedList = await _centralDbContext.Requests + .Where(r => r.UserId == request.UserId) + .ToListAsync(); return Json(updatedList); } @@ -757,20 +755,22 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory } } - [HttpGet("ItemRequestListEachUser/{id}")] - public async Task ItemRequestListEachUser(int UserId) + + + [HttpGet("ItemRequestListEachUser/{userId}")] + public async Task ItemRequestListEachUser(int userId) { + var requests = await _centralDbContext.Requests + .Where(r => r.UserId == userId).ToListAsync(); - var itemRequestList = await _centralDbContext.Requests.Where(r => r.UserId == UserId).ToListAsync(); - - return Json(itemRequestList); - + return Ok(requests); } - [HttpDelete("DeleteRequest/{id}")] - public async Task DeleteRequest(int id) + + [HttpDelete("DeleteRequest/{requestId}")] + public async Task DeleteRequest(int requestId) { - var request = await _centralDbContext.Requests.FindAsync(id); + var request = await _centralDbContext.Requests.FindAsync(requestId); if (request == null) { return NotFound(new { success = false, message = "Request not found" }); diff --git a/PSTW_CentralSystem.csproj b/PSTW_CentralSystem.csproj index 5d87e57..c18ba39 100644 --- a/PSTW_CentralSystem.csproj +++ b/PSTW_CentralSystem.csproj @@ -6,6 +6,10 @@ enable + + + + diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml index 1a0b69b..6fbf781 100644 --- a/Views/Shared/_Layout.cshtml +++ b/Views/Shared/_Layout.cshtml @@ -440,6 +440,13 @@ AdminDashboard +