@* Item Price in RM *@
@@ -355,9 +378,9 @@
purchaseDate: null,
PO: null,
currency: "MYR",
- priceInRM: 0.01,
+ DefaultPrice: 0.01,
currencyRate: 1,
- convertPrice: 0,
+ convertPrice: 0.01,
DONo:null,
DODate: null,
warranty: 0,
@@ -381,24 +404,28 @@
selectedSupplier: "",
selectedCompany: "",
selectedDepartment: "",
+ selectedTeamType: "",
currencies: {},
showItemModal: false,
loading: false,
- thisQR: null,
+ thisQRInfo: {
+ uniqueID: null,
+ departmentName: null,
+ serialNumber: null,
+ endWDate: null,
+ },
items: [],
currentUser: null,
-
+ currentUserCompanyDept: null,
}
},
- mounted() {// Log the token to check its value
-
- // Fetch companies, depts, and products from the API
+ mounted() {
+ this.fetchUser();
this.fetchItem();
this.fetchCurrencyData();
this.fetchCompanies();
this.fetchProducts();
this.fetchSuppliers();
- this.fetchUser();
},
computed: {
filteredDepartments() {
@@ -406,6 +433,7 @@
return []; // No company selected, return empty list
}
const company = this.companies.find(c => c.companyId === this.selectedCompany);
+ this.selectedDepartment = '';
return company ? company.departments : [];
},
showProduct() {
@@ -434,14 +462,15 @@
PurchaseDate: this.purchaseDate,
PONo: this.PO,
Currency: this.currency,
- PriceInRM: this.priceInRM,
+ DefaultPrice: this.DefaultPrice,
CurrencyRate: this.currencyRate,
ConvertPrice: this.convertPrice,
DODate: this.DODate,
Warranty: this.warranty,
EndWDate: this.EndWDate,
InvoiceDate: this.invoiceDate,
- CreatedByUserId: this.currentUser,
+ CreatedByUserId: this.currentUser.id,
+ TeamType: this.selectedTeamType,
};
try {
@@ -548,7 +577,7 @@
{
"title": "Print",
"data": "uniqueID",
- "render": function (data) {
+ "render": function (data, type, full, meta) {
var printButton = `
`;
return printButton;
},
@@ -708,7 +737,7 @@
this.purchaseDate = null;
this.PO = null;
this.currency = null;
- this.priceInRM = null;
+ this.DefaultPrice = null;
this.currencyRate = null;
this.convertPrice = null;
this.DODate = null;
@@ -719,15 +748,17 @@
this.selectedSupplier = "";
this.selectedCompany = "";
this.selectedDepartment = "";
+ this.currentUserCompanyDept = null;
+ this.selectedTeamType = "";
},
// FRONT END FUNCTIONS
//----------------------//
//Calculate Total Price
convertCurrency() {
- const total = this.priceInRM * this.currencyRate;
+ const total = this.DefaultPrice * this.currencyRate;
this.convertPrice = total.toFixed(2);
- this.priceInRM = this.priceInRM
+ this.DefaultPrice = this.DefaultPrice
// .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points
// .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point
// .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places
@@ -812,14 +843,28 @@
},
async printItem(itemId, imgSrc) {
try {
- this.thisQR = itemId;
+ this.thisQRInfo.uniqueID = itemId;
+ const uniqueQR = itemId;
const container = document.getElementById("QrContainer");
+
if (!container) {
- console.error(`Container not found.`);
+ console.error("Container not found.");
return;
}
- container.innerHTML = `

`;
- $(`#QrItemModal`).modal('show');
+
+ // Safely set image content
+ const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL
+ container.innerHTML = `

`;
+
+ // Fetch QR information
+ const qrInfo = this.getPrintedQR(uniqueQR);
+ if (!qrInfo) {
+ console.error("QR Info not found.");
+ return;
+ }
+
+ this.thisQRInfo = qrInfo; // Save the QR info to a property
+ $(`#QrItemModal`).modal('show'); // Show modal
}
catch (error) {
console.error("Error generating QR code:", error);
@@ -833,7 +878,10 @@
});
if (response.ok) {
const data = await response.json();
- this.currentUser = data?.UserInfo || null;
+ this.currentUser = data?.userInfo || null;
+ const companyDeptData = await this.currentUser.department;
+ this.currentUserCompanyDept = companyDeptData;
+ this.selectedCompany = companyDeptData?.companyId || "";
}
else {
console.error(`Failed to fetch user: ${response.statusText}`);
@@ -843,6 +891,13 @@
console.error('There was a problem with the fetch operation:', error);
}
},
+ getPrintedQR(uniqueID) {
+ if (!this.items || !Array.isArray(this.items)) {
+ console.error("Items list is not available or is not an array.");
+ return null;
+ }
+ return this.items.find(item => item.uniqueID === uniqueID);
+ },
},
});
diff --git a/Controllers/API/AdminAPI.cs b/Controllers/API/AdminAPI.cs
index e711d1d..2ad1a4f 100644
--- a/Controllers/API/AdminAPI.cs
+++ b/Controllers/API/AdminAPI.cs
@@ -18,12 +18,12 @@ namespace PSTW_CentralSystem.Controllers.API
public class AdminAPI : Controller
{
private readonly ILogger
_logger;
- private readonly IdentityDBContext _identityDbContext;
+ private readonly CentralSystemContext _identityDbContext;
private readonly UserManager _userManager;
private readonly SignInManager _signInManager;
private readonly RoleManager _roleManager;
- public AdminAPI(ILogger logger, IdentityDBContext authDbContext, UserManager userManager, SignInManager signInManager, RoleManager roleManager)
+ public AdminAPI(ILogger logger, CentralSystemContext authDbContext, UserManager userManager, SignInManager signInManager, RoleManager roleManager)
{
_logger = logger;
_identityDbContext = authDbContext;
diff --git a/Controllers/API/IdentityAPI.cs b/Controllers/API/IdentityAPI.cs
index dc9204f..77d003c 100644
--- a/Controllers/API/IdentityAPI.cs
+++ b/Controllers/API/IdentityAPI.cs
@@ -14,14 +14,14 @@ namespace PSTW_CentralSystem.Controllers.API
public class IdentityAPI : Controller
{
private readonly ILogger _logger;
- private readonly IdentityDBContext _identityDbContext;
+ private readonly CentralSystemContext _identityDbContext;
private readonly UserManager _userManager;
private readonly SignInManager _signInManager;
// Communication Key for API. Not API authentication key
private readonly string _commKey = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF4NW42anlkNlpTYzZNSE1Zem9qaApUbldpYTIra2pud2ZNbVhpSWlyK0RadjM2cEVGMGhRUWFLaWpaMWtyMGNiT25Ha2d2QnNwTzNiYkFua0E3SWwzCk4zM3NNYWdQV0JOQzZyVm1jT04zNEhDSWJCM0hvQXFYQUtkSHFUOGZneklMRzFhRzdxK2h4RDZhZzZsemhTMnEKdDA1bHdNc0hONWpOdmVNNnFWalRnTVB4aEFOMUhnUTkrd1lRWFh5bnZYYUo5OUNySHBqS21WdUt2VUh6WXdlRwp6SnBtYXZOclc4bE9oM1lMeVNuUVU5bjRrdURubGc1OWNHeUtKbzJ2YUxZbll4MkR1ZDNabzBXMHRMWGd0dlQyCjVXdVFsY0NVbldvaVpBV1JBTGI3anRpcTF0MGY5eVBiV2gxYXpMMjFoL3QvckJUMXNCL2FQd2kzRCt3MnBUR00KeVFJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";
- public IdentityAPI(ILogger logger, IdentityDBContext authDbContext, UserManager userManager, SignInManager signInManager)
+ public IdentityAPI(ILogger logger, CentralSystemContext authDbContext, UserManager userManager, SignInManager signInManager)
{
_logger = logger;
_identityDbContext = authDbContext;
@@ -29,6 +29,7 @@ namespace PSTW_CentralSystem.Controllers.API
_signInManager = signInManager;
}
+ #region User
[HttpPost("GetUserInformation")]
public async Task GetUserInformation()
{
@@ -62,7 +63,9 @@ namespace PSTW_CentralSystem.Controllers.API
return StatusCode(500, $"An error occurred: {ex.Message}");
}
}
+ #endregion User
+ #region LDAP Login
[HttpPost("LdapLogin")]
public async Task LdapLogin([FromBody] LdapLoginCredential ldapLoginInfo)
{
@@ -135,7 +138,7 @@ namespace PSTW_CentralSystem.Controllers.API
await _signInManager.SignInAsync(existUser, false);
- if (existUser.UserInfoStatus == null || existUser.UserInfoStatus != 0)
+ if (existUser.UserInfoStatus == null || existUser.UserInfoStatus == 0)
{
return Ok(new { RedirectUrl = Url.Action("ComDeptAssignment", "Identity") });
}
@@ -143,6 +146,8 @@ namespace PSTW_CentralSystem.Controllers.API
return Ok(new { RedirectUrl = Url.Action("Index", "Home") });
}
+ #endregion LDAP Login
+
#region Company
[HttpPost("CompanyDepartmentList")]
@@ -183,8 +188,6 @@ namespace PSTW_CentralSystem.Controllers.API
return Json(itemDepartment);
}
- #endregion Department
-
[HttpPost("UserComptDeptAssignment/{id}")]
public async Task UserComptDeptAssignment([FromBody] UserDeptAssignment userDeptAssignment, int id)
{
@@ -204,6 +207,8 @@ namespace PSTW_CentralSystem.Controllers.API
return Ok( new { message = "User updated successfully", RedirectUrl = Url.Action("Index", "Home") });
}
+ #endregion Department
+
public async Task doUserExists(string username)
{
var user = await _userManager.FindByNameAsync(username);
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 08c7e25..a9e3e1e 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -18,14 +18,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public class InvMainAPI : Controller
{
private readonly ILogger _logger;
- private readonly IdentityDBContext _identityDbContext;
- private readonly InventoryDBContext _inventoryDbContext;
+ private readonly CentralSystemContext _centralDbContext;
- public InvMainAPI(ILogger logger, IdentityDBContext authDbContext, InventoryDBContext inventoryDbContext)
+ public InvMainAPI(ILogger logger, CentralSystemContext centralDbContext)
{
_logger = logger;
- _identityDbContext = authDbContext;
- _inventoryDbContext = inventoryDbContext;
+ _centralDbContext = centralDbContext;
}
public class DepartmentCompany
@@ -34,12 +32,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public string? DepartmentName { get; set; }
public int CompanyId { get; set; }
public string? CompanyName { get; set; }
+ public string? DepartmentCode { get; set; }
}
public async Task> GetDepartmentWithCompanyList()
{
- var departmentList = await _identityDbContext.Departments.ToListAsync();
- var companyList = await _identityDbContext.Companies.ToListAsync();
+ var departmentList = await _centralDbContext.Departments.ToListAsync();
+ var companyList = await _centralDbContext.Companies.ToListAsync();
// Create a new list to store departments with their company name
var departmentWithCompanyList = departmentList.Select(department => new DepartmentCompany
@@ -55,8 +54,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
}
public async Task GetDepartmentWithCompany(int companyId, int departmentId)
{
- var departmentList = await _identityDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId );
- var companyList = await _identityDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId);
+ var departmentList = await _centralDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId );
+ var companyList = await _centralDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId);
// Create a new list to store departments with their company name
var departmentWithCompany = new DepartmentCompany
@@ -64,7 +63,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
DepartmentId = departmentList!.DepartmentId,
DepartmentName = departmentList.DepartmentName,
CompanyId = departmentList.CompanyId,
- CompanyName = companyList?.CompanyName
+ CompanyName = companyList?.CompanyName,
+ DepartmentCode = departmentList.DepartmentCode,
};
// Return the constructed list as JSON
@@ -76,7 +76,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ManufacturerList")]
public async Task ManufacturerList()
{
- var manifacturerList = await _inventoryDbContext.Manufacturers.ToListAsync();
+ var manifacturerList = await _centralDbContext.Manufacturers.ToListAsync();
return Json(manifacturerList);
}
@@ -87,19 +87,15 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
return BadRequest(ModelState);
}
- if (manufacturer == null)
- {
- return NotFound("Manufacturer is null");
- }
try
{
- _inventoryDbContext.Manufacturers.Add(new ManufacturerModel
+ _centralDbContext.Manufacturers.Add(new ManufacturerModel
{
ManufacturerName = manufacturer.ManufacturerName,
});
- await _identityDbContext.SaveChangesAsync();
- var updatedList = await _inventoryDbContext.Manufacturers.ToListAsync();
+ await _centralDbContext.SaveChangesAsync();
+ var updatedList = await _centralDbContext.Manufacturers.ToListAsync();
return Json(updatedList);
}
catch (Exception ex)
@@ -111,14 +107,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteManufacturer/{id}")]
public async Task DeleteManufacturer(int id)
{
- var manufacturer = await _inventoryDbContext.Manufacturers.FindAsync(id);
+ var manufacturer = await _centralDbContext.Manufacturers.FindAsync(id);
if (manufacturer == null)
{
return NotFound(new { success = false, message = "Manufacturer not found" });
}
- _inventoryDbContext.Manufacturers.Remove(manufacturer);
- await _identityDbContext.SaveChangesAsync();
+ _centralDbContext.Manufacturers.Remove(manufacturer);
+ await _centralDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Manufacturer deleted successfully" });
}
@@ -130,14 +126,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ProductList")]
public async Task ProductList()
{
- var productList = await _inventoryDbContext.Products.Include("Manufacturer").ToListAsync();
+ var productList = await _centralDbContext.Products.Include("Manufacturer").ToListAsync();
return Json(productList);
}
[HttpPost("ProductListWithItem")]
public async Task ProductListWithItem()
{
- var productList = await _inventoryDbContext.Products
+ var productList = await _centralDbContext.Products
.Include(p => p.Items) // Include related items
.Include(p => p.Manufacturer) // Include related manufacturer
.ToListAsync();
@@ -169,9 +165,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
await System.IO.File.WriteAllBytesAsync(filePath, bytes);
product.ImageProduct = "/media/inventory/images/" + product.ModelNo + ".jpg";
}
- _inventoryDbContext.Products.Add(product);
- await _identityDbContext.SaveChangesAsync();
- var updatedList = await _inventoryDbContext.Products.Include("Manufacturer").Where(x => x.ManufacturerId == x.ManufacturerId).ToListAsync();
+ _centralDbContext.Products.Add(product);
+ await _centralDbContext.SaveChangesAsync();
+ var updatedList = await _centralDbContext.Products.Include("Manufacturer").Where(x => x.ManufacturerId == x.ManufacturerId).ToListAsync();
return Json(updatedList);
}
catch (Exception ex)
@@ -183,27 +179,26 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteProduct/{id}")]
public async Task DeleteProduct(int id)
{
- var Product = await _inventoryDbContext.Products.FindAsync(id);
+ var Product = await _centralDbContext.Products.FindAsync(id);
if (Product == null)
{
return NotFound(new { success = false, message = "Product not found" });
}
- _inventoryDbContext.Products.Remove(Product);
- await _identityDbContext.SaveChangesAsync();
+ _centralDbContext.Products.Remove(Product);
+ await _centralDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Product deleted successfully" });
}
#endregion Product
-
#region Supplier
[HttpPost("SupplierList")]
public async Task SupplierList()
{
- var supplierList = await _inventoryDbContext.Suppliers.ToListAsync();
+ var supplierList = await _centralDbContext.Suppliers.ToListAsync();
return Json(supplierList);
}
@@ -214,11 +209,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ItemList")]
public async Task ItemList()
{
- var itemList = await _inventoryDbContext.Items.ToListAsync();
- // Retrieve the request's host and scheme
- var request = HttpContext.Request;
- string domain = $"{request.Scheme}://{request.Host.Value}";
- var itemListWithQR = itemList.Select(item => new
+ // Get the item list
+ var itemList = await _centralDbContext.Items.Include("CreatedBy").Include("Department").Include("Product").ToListAsync();
+
+ // Get the departments list (DepartmentId references Departments)
+ var departments = await _centralDbContext.Departments.ToListAsync();
+
+ // Now join items with users and departments manually
+ var itemListWithDetails = itemList.Select(item => new
{
item.ItemID,
item.UniqueID,
@@ -231,18 +229,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.PurchaseDate,
item.PONo,
item.Currency,
- item.PriceInRM,
+ item.DefaultPrice,
item.CurrencyRate,
item.ConvertPrice,
item.DODate,
item.Warranty,
item.EndWDate,
item.InvoiceDate,
- QRString = $"{domain}/Inventory/ItemInformation/{item.UniqueID}"
+ item.Department?.DepartmentName,
+ item.CreatedBy!.UserName,
+ item.Product!.ProductName,
+ QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/Inventory/ItemInformation/{item.UniqueID}" // Generate QR String
}).ToList();
- return Json(itemListWithQR);
+
+ return Json(itemListWithDetails);
}
+
+
[HttpPost("GenerateItemQr/{id}")]
public IActionResult GenerateItemQr(string id)
{
@@ -262,14 +266,10 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
return BadRequest(ModelState);
}
- if (item == null)
- {
- return NotFound("Item is null");
- }
try
{
- var product = await _inventoryDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found");
+ var product = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found");
var addToProduct = item.Quantity;
product.QuantityProduct += addToProduct;
@@ -279,28 +279,30 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.SerialNumber = null;
}
- _inventoryDbContext.Items.Add(item);
- _inventoryDbContext.Products.Update(product);
- await _identityDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID
+ _centralDbContext.Items.Add(item);
+ _centralDbContext.Products.Update(product);
+
+ await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID
// Fetch the generated ItemID
- var savedItem = await _inventoryDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID);
+ var savedItem = await _centralDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID);
if (savedItem != null)
{
var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId);
- var itemProduct = _inventoryDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault();
+ var itemProduct = _centralDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault();
string? companyInitial = companyDepartment!.CompanyName?.ToString().Substring(0, 1).ToUpper();
string? departmentInitial = companyDepartment!.DepartmentName?.ToString().Substring(0, 1).ToUpper();
+ string? deptCode = companyDepartment!.DepartmentCode?.ToString();
char? initialCategory = itemProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault();
string? productId = itemProduct!.ProductId.ToString("D3");
string? itemId = item.ItemID.ToString("D5");
- var uniqueId = $"{companyInitial}{departmentInitial}{initialCategory}{productId}{itemId}".ToUpper();
+ var uniqueId = $"{deptCode}{initialCategory}{productId}{itemId}".ToUpper();
savedItem.UniqueID = uniqueId;
- _inventoryDbContext.Items.Update(savedItem);
- await _identityDbContext.SaveChangesAsync();
+ _centralDbContext.Items.Update(savedItem);
+ await _centralDbContext.SaveChangesAsync();
}
var updatedItem = new
{
@@ -315,7 +317,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
savedItem.PurchaseDate,
savedItem.PONo,
savedItem.Currency,
- savedItem.PriceInRM,
+ savedItem.DefaultPrice,
savedItem.CurrencyRate,
savedItem.ConvertPrice,
savedItem.DODate,
@@ -334,14 +336,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteItem/{id}")]
public async Task DeleteItem(int id)
{
- var item = await _inventoryDbContext.Items.FindAsync(id);
+ var item = await _centralDbContext.Items.FindAsync(id);
if (item == null)
{
return NotFound(new { success = false, message = "Item not found" });
}
- _inventoryDbContext.Items.Remove(item);
- await _identityDbContext.SaveChangesAsync();
+ _centralDbContext.Items.Remove(item);
+ await _centralDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Item deleted successfully" });
}
diff --git a/Controllers/API/ModuleAPI.cs b/Controllers/API/ModuleAPI.cs
index 79deead..377a6fc 100644
--- a/Controllers/API/ModuleAPI.cs
+++ b/Controllers/API/ModuleAPI.cs
@@ -11,8 +11,8 @@ namespace PSTW_CentralSystem.Controllers.API
public class ModuleAPI : Controller
{
private readonly ILogger _logger;
- private readonly IdentityDBContext _authDbContext;
- public ModuleAPI(ILogger logger, IdentityDBContext authDbContext)
+ private readonly CentralSystemContext _authDbContext;
+ public ModuleAPI(ILogger logger, CentralSystemContext authDbContext)
{
_logger = logger;
_authDbContext = authDbContext;
diff --git a/Controllers/API/RoleAPI.cs b/Controllers/API/RoleAPI.cs
index 4d305fd..0ac8133 100644
--- a/Controllers/API/RoleAPI.cs
+++ b/Controllers/API/RoleAPI.cs
@@ -14,10 +14,10 @@ namespace PSTW_CentralSystem.Controllers.API
public class RoleAPI : Controller
{
private readonly ILogger _logger;
- private readonly IdentityDBContext _authDbContext;
+ private readonly CentralSystemContext _authDbContext;
private readonly RoleManager _roleManager;
- public RoleAPI(ILogger logger, IdentityDBContext authDbContext, RoleManager roleManager)
+ public RoleAPI(ILogger logger, CentralSystemContext authDbContext, RoleManager roleManager)
{
_logger = logger;
_authDbContext = authDbContext;
diff --git a/Controllers/AdminController.cs b/Controllers/AdminController.cs
index e1135bf..4bf1284 100644
--- a/Controllers/AdminController.cs
+++ b/Controllers/AdminController.cs
@@ -9,10 +9,10 @@ namespace PSTW_CentralSystem.Controllers
[Authorize(Policy = "RoleModulePolicy")]
public class AdminController : Controller
{
- private readonly IdentityDBContext _authDbContext;
+ private readonly CentralSystemContext _authDbContext;
private readonly ILogger _logger;
- public AdminController(ILogger logger, IdentityDBContext authDbContext)
+ public AdminController(ILogger logger, CentralSystemContext authDbContext)
{
_logger = logger;
_authDbContext = authDbContext;
diff --git a/Controllers/IdentityController.cs b/Controllers/IdentityController.cs
index d9a082d..ac37a3d 100644
--- a/Controllers/IdentityController.cs
+++ b/Controllers/IdentityController.cs
@@ -12,10 +12,10 @@ namespace PSTW_CentralSystem.Controllers
public class IdentityController: Controller
{
private readonly ILogger _logger;
- private readonly IdentityDBContext _authDbContext;
+ private readonly CentralSystemContext _authDbContext;
private readonly UserManager _userManager;
- public IdentityController(ILogger logger, IdentityDBContext authDbContext, UserManager userManager)
+ public IdentityController(ILogger logger, CentralSystemContext authDbContext, UserManager userManager)
{
_logger = logger;
_authDbContext = authDbContext;
diff --git a/CustomPolicy/RoleModulePolicy.cs b/CustomPolicy/RoleModulePolicy.cs
index e8a8f2d..a0fc0c0 100644
--- a/CustomPolicy/RoleModulePolicy.cs
+++ b/CustomPolicy/RoleModulePolicy.cs
@@ -14,11 +14,11 @@ namespace PSTW_CentralSystem.CustomPolicy
}
public class RoleModuleHandler : AuthorizationHandler
{
- private readonly IdentityDBContext _authDBContext;
+ private readonly CentralSystemContext _authDBContext;
private readonly UserManager _userManager;
private readonly RoleManager _roleManager;
private readonly IHttpContextAccessor _httpContextAccessor;
- public RoleModuleHandler( IdentityDBContext authDBContext, UserManager userManager, RoleManager roleManager, IHttpContextAccessor httpContextAccessor)
+ public RoleModuleHandler( CentralSystemContext authDBContext, UserManager userManager, RoleManager roleManager, IHttpContextAccessor httpContextAccessor)
{
_authDBContext = authDBContext;
_userManager = userManager;
diff --git a/DBContext/IdentityDBContext.cs b/DBContext/CentralSystemContext.cs
similarity index 88%
rename from DBContext/IdentityDBContext.cs
rename to DBContext/CentralSystemContext.cs
index 821e617..caf8fd6 100644
--- a/DBContext/IdentityDBContext.cs
+++ b/DBContext/CentralSystemContext.cs
@@ -9,10 +9,10 @@ using System.Text.Json;
namespace PSTW_CentralSystem.DBContext
{
- public class IdentityDBContext : IdentityDbContext
+ public class CentralSystemContext : IdentityDbContext
{
private readonly IWebHostEnvironment _hostingEnvironment;
- public IdentityDBContext(DbContextOptions options, IWebHostEnvironment hostingEnvironment) : base(options)
+ public CentralSystemContext(DbContextOptions options, IWebHostEnvironment hostingEnvironment) : base(options)
{
_hostingEnvironment = hostingEnvironment;
}
@@ -20,7 +20,7 @@ namespace PSTW_CentralSystem.DBContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
-
+ //modelBuilder.HasDefaultSchema("CentralSystem");
modelBuilder.Entity()
.Property(e => e.MethodAllowedUserType)
.HasConversion(
@@ -87,6 +87,10 @@ namespace PSTW_CentralSystem.DBContext
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/DBContext/InventoryDBContext.cs b/DBContext/InventoryDBContext.cs
deleted file mode 100644
index 47166dd..0000000
--- a/DBContext/InventoryDBContext.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json;
-using PSTW_CentralSystem.Areas.Inventory.Models;
-using PSTW_CentralSystem.Models;
-
-namespace PSTW_CentralSystem.DBContext
-{
- public class InventoryDBContext : DbContext
- {
- private readonly IWebHostEnvironment _hostingEnvironment;
- public InventoryDBContext(DbContextOptions options, IWebHostEnvironment hostingEnvironment) : base(options)
- {
- _hostingEnvironment = hostingEnvironment;
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- }
-
- public DbSet Manufacturers { get; set; }
- public DbSet Items { get; set; }
- public DbSet Products { get; set; }
- public DbSet Suppliers { get; set; }
- }
-}
diff --git a/Migrations/20241218060528_Initiate.Designer.cs b/Migrations/20241223071002_Initiate.Designer.cs
similarity index 65%
rename from Migrations/20241218060528_Initiate.Designer.cs
rename to Migrations/20241223071002_Initiate.Designer.cs
index 8467a4a..eaaea2d 100644
--- a/Migrations/20241218060528_Initiate.Designer.cs
+++ b/Migrations/20241223071002_Initiate.Designer.cs
@@ -11,8 +11,8 @@ using PSTW_CentralSystem.DBContext;
namespace PSTW_CentralSystem.Migrations
{
- [DbContext(typeof(IdentityDBContext))]
- [Migration("20241218060528_Initiate")]
+ [DbContext(typeof(CentralSystemContext))]
+ [Migration("20241223071002_Initiate")]
partial class Initiate
{
///
@@ -140,6 +140,185 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("AspNetUserTokens", (string)null);
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
+ {
+ b.Property("ItemID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID"));
+
+ b.Property("CompanyId")
+ .HasColumnType("int");
+
+ b.Property("ConvertPrice")
+ .HasColumnType("float");
+
+ b.Property("CreatedByUserId")
+ .HasColumnType("int");
+
+ b.Property("Currency")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("CurrencyRate")
+ .HasColumnType("float");
+
+ b.Property("DODate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DONo")
+ .HasColumnType("longtext");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("EndWDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("InvoiceDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("InvoiceNo")
+ .HasColumnType("longtext");
+
+ b.Property("ItemLocation")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ItemStatus")
+ .HasColumnType("int")
+ .HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
+
+ b.Property("PONo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("DefaultPrice")
+ .HasColumnType("float");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ b.Property("SerialNumber")
+ .HasColumnType("longtext");
+
+ b.Property("Supplier")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("TeamType")
+ .HasColumnType("longtext");
+
+ b.Property("UniqueID")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Warranty")
+ .HasColumnType("int");
+
+ b.HasKey("ItemID");
+
+ b.HasIndex("CompanyId");
+
+ b.HasIndex("CreatedByUserId");
+
+ b.HasIndex("DepartmentId");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("Items");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
+ {
+ b.Property("ManufacturerId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ManufacturerId"));
+
+ b.Property("ManufacturerName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("ManufacturerId");
+
+ b.ToTable("Manufacturers");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.Property("ProductId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProductId"));
+
+ b.Property("Category")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ImageProduct")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ManufacturerId")
+ .HasColumnType("int");
+
+ b.Property("ModelNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("QuantityProduct")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId");
+
+ b.HasIndex("ManufacturerId");
+
+ b.ToTable("Products");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
+ {
+ b.Property("SupplierId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SupplierId"));
+
+ b.Property("SupplierEmail")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierGender")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierPhoneNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("SupplierId");
+
+ b.ToTable("Suppliers");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
{
b.Property("CompanyId")
@@ -357,16 +536,16 @@ namespace PSTW_CentralSystem.Migrations
{
Id = 1,
AccessFailedCount = 0,
- ConcurrencyStamp = "f89f9499-14a5-4bba-a003-5bbb0ef1bb12",
+ ConcurrencyStamp = "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c",
Email = "admin@pstw.com.my",
EmailConfirmed = true,
FullName = "MAAdmin",
LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY",
- PasswordHash = "AQAAAAIAAYagAAAAEDue4k8/8FwBvdJbbgBDLH+ibzmThXls6CmbJd99AdlrbPZrOWvWxlkv7cwVsPSM9g==",
+ PasswordHash = "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==",
PhoneNumberConfirmed = false,
- SecurityStamp = "d5684375-c368-409a-82e1-1e44fa05de60",
+ SecurityStamp = "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d",
TwoFactorEnabled = false,
UserInfoStatus = 1,
UserName = "admin@pstw.com.my"
@@ -375,16 +554,16 @@ namespace PSTW_CentralSystem.Migrations
{
Id = 2,
AccessFailedCount = 0,
- ConcurrencyStamp = "d19f378c-eef5-4cf7-8ec6-c6b3904e4749",
+ ConcurrencyStamp = "fd4022cd-e08a-43c1-823c-573a86e86a9d",
Email = "sysadmin@pstw.com.my",
EmailConfirmed = true,
FullName = "SysAdmin",
LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
- PasswordHash = "AQAAAAIAAYagAAAAEDme/kiOHre+s0r9XvpwSr5dZIoWIbSJhI5B19mCjH4ZFoBBlF6Pay9WYJ2jcVZgfw==",
+ PasswordHash = "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==",
PhoneNumberConfirmed = false,
- SecurityStamp = "7875eac4-323d-43cb-a083-940e52877171",
+ SecurityStamp = "0b4291c9-d818-4485-bd96-adde7e14286d",
TwoFactorEnabled = false,
UserInfoStatus = 1,
UserName = "sysadmin@pstw.com.my"
@@ -442,6 +621,52 @@ namespace PSTW_CentralSystem.Migrations
.IsRequired();
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
+ {
+ b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
+ .WithMany()
+ .HasForeignKey("CompanyId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Models.UserModel", "CreatedBy")
+ .WithMany()
+ .HasForeignKey("CreatedByUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
+ .WithMany()
+ .HasForeignKey("DepartmentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
+ .WithMany("Items")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Company");
+
+ b.Navigation("CreatedBy");
+
+ b.Navigation("Department");
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
+ .WithMany()
+ .HasForeignKey("ManufacturerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manufacturer");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@@ -462,6 +687,11 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department");
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.Navigation("Items");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
{
b.Navigation("Departments");
diff --git a/Migrations/20241218060528_Initiate.cs b/Migrations/20241223071002_Initiate.cs
similarity index 64%
rename from Migrations/20241218060528_Initiate.cs
rename to Migrations/20241223071002_Initiate.cs
index 8b7fa5b..4ff2e74 100644
--- a/Migrations/20241218060528_Initiate.cs
+++ b/Migrations/20241223071002_Initiate.cs
@@ -53,6 +53,21 @@ namespace PSTW_CentralSystem.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
+ migrationBuilder.CreateTable(
+ name: "Manufacturers",
+ columns: table => new
+ {
+ ManufacturerId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ ManufacturerName = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Manufacturers", x => x.ManufacturerId);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
migrationBuilder.CreateTable(
name: "ModuleSettings",
columns: table => new
@@ -75,6 +90,27 @@ namespace PSTW_CentralSystem.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
+ migrationBuilder.CreateTable(
+ name: "Suppliers",
+ columns: table => new
+ {
+ SupplierId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ SupplierName = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ SupplierGender = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ SupplierEmail = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ SupplierPhoneNo = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Suppliers", x => x.SupplierId);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
@@ -123,6 +159,35 @@ namespace PSTW_CentralSystem.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
+ migrationBuilder.CreateTable(
+ name: "Products",
+ columns: table => new
+ {
+ ProductId = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ ProductName = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ManufacturerId = table.Column(type: "int", nullable: false),
+ Category = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ModelNo = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ QuantityProduct = table.Column(type: "int", nullable: true),
+ ImageProduct = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Products", x => x.ProductId);
+ table.ForeignKey(
+ name: "FK_Products_Manufacturers_ManufacturerId",
+ column: x => x.ManufacturerId,
+ principalTable: "Manufacturers",
+ principalColumn: "ManufacturerId",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
@@ -264,6 +329,75 @@ namespace PSTW_CentralSystem.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
+ migrationBuilder.CreateTable(
+ name: "Items",
+ columns: table => new
+ {
+ ItemID = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ UniqueID = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CompanyId = table.Column(type: "int", nullable: false),
+ DepartmentId = table.Column(type: "int", nullable: false),
+ ProductId = table.Column(type: "int", nullable: false),
+ SerialNumber = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ TeamType = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ Quantity = table.Column(type: "int", nullable: false),
+ Supplier = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ PurchaseDate = table.Column(type: "datetime(6)", nullable: false),
+ PONo = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ Currency = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ PriceInRM = table.Column(type: "float", nullable: false),
+ CurrencyRate = table.Column(type: "float", nullable: false),
+ ConvertPrice = table.Column(type: "float", nullable: false),
+ DONo = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ DODate = table.Column(type: "datetime(6)", nullable: true),
+ Warranty = table.Column(type: "int", nullable: false),
+ EndWDate = table.Column(type: "datetime(6)", nullable: false),
+ InvoiceNo = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ InvoiceDate = table.Column(type: "datetime(6)", nullable: true),
+ ItemStatus = table.Column(type: "int", nullable: false, comment: "1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"),
+ ItemLocation = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CreatedByUserId = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Items", x => x.ItemID);
+ table.ForeignKey(
+ name: "FK_Items_AspNetUsers_CreatedByUserId",
+ column: x => x.CreatedByUserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Items_Companies_CompanyId",
+ column: x => x.CompanyId,
+ principalTable: "Companies",
+ principalColumn: "CompanyId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Items_Departments_DepartmentId",
+ column: x => x.DepartmentId,
+ principalTable: "Departments",
+ principalColumn: "DepartmentId",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Items_Products_ProductId",
+ column: x => x.ProductId,
+ principalTable: "Products",
+ principalColumn: "ProductId",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
migrationBuilder.InsertData(
table: "AspNetRoles",
columns: new[] { "Id", "ConcurrencyStamp", "Description", "Name", "NormalizedName" },
@@ -280,8 +414,8 @@ namespace PSTW_CentralSystem.Migrations
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FullName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserInfoStatus", "UserName", "departmentId" },
values: new object[,]
{
- { 1, 0, "f89f9499-14a5-4bba-a003-5bbb0ef1bb12", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEDue4k8/8FwBvdJbbgBDLH+ibzmThXls6CmbJd99AdlrbPZrOWvWxlkv7cwVsPSM9g==", null, false, "d5684375-c368-409a-82e1-1e44fa05de60", false, 1, "admin@pstw.com.my", null },
- { 2, 0, "d19f378c-eef5-4cf7-8ec6-c6b3904e4749", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEDme/kiOHre+s0r9XvpwSr5dZIoWIbSJhI5B19mCjH4ZFoBBlF6Pay9WYJ2jcVZgfw==", null, false, "7875eac4-323d-43cb-a083-940e52877171", false, 1, "sysadmin@pstw.com.my", null }
+ { 1, 0, "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==", null, false, "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d", false, 1, "admin@pstw.com.my", null },
+ { 2, 0, "fd4022cd-e08a-43c1-823c-573a86e86a9d", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==", null, false, "0b4291c9-d818-4485-bd96-adde7e14286d", false, 1, "sysadmin@pstw.com.my", null }
});
migrationBuilder.InsertData(
@@ -339,6 +473,31 @@ namespace PSTW_CentralSystem.Migrations
name: "IX_Departments_CompanyId",
table: "Departments",
column: "CompanyId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Items_CompanyId",
+ table: "Items",
+ column: "CompanyId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Items_CreatedByUserId",
+ table: "Items",
+ column: "CreatedByUserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Items_DepartmentId",
+ table: "Items",
+ column: "DepartmentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Items_ProductId",
+ table: "Items",
+ column: "ProductId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Products_ManufacturerId",
+ table: "Products",
+ column: "ManufacturerId");
}
///
@@ -359,18 +518,30 @@ namespace PSTW_CentralSystem.Migrations
migrationBuilder.DropTable(
name: "AspNetUserTokens");
+ migrationBuilder.DropTable(
+ name: "Items");
+
migrationBuilder.DropTable(
name: "ModuleSettings");
+ migrationBuilder.DropTable(
+ name: "Suppliers");
+
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
+ migrationBuilder.DropTable(
+ name: "Products");
+
migrationBuilder.DropTable(
name: "Departments");
+ migrationBuilder.DropTable(
+ name: "Manufacturers");
+
migrationBuilder.DropTable(
name: "Companies");
}
diff --git a/Migrations/IdentityDBContextModelSnapshot.cs b/Migrations/CentralSystemContextModelSnapshot.cs
similarity index 64%
rename from Migrations/IdentityDBContextModelSnapshot.cs
rename to Migrations/CentralSystemContextModelSnapshot.cs
index e17e091..9fd3baa 100644
--- a/Migrations/IdentityDBContextModelSnapshot.cs
+++ b/Migrations/CentralSystemContextModelSnapshot.cs
@@ -10,8 +10,8 @@ using PSTW_CentralSystem.DBContext;
namespace PSTW_CentralSystem.Migrations
{
- [DbContext(typeof(IdentityDBContext))]
- partial class IdentityDBContextModelSnapshot : ModelSnapshot
+ [DbContext(typeof(CentralSystemContext))]
+ partial class CentralSystemContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
@@ -137,6 +137,185 @@ namespace PSTW_CentralSystem.Migrations
b.ToTable("AspNetUserTokens", (string)null);
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
+ {
+ b.Property("ItemID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID"));
+
+ b.Property("CompanyId")
+ .HasColumnType("int");
+
+ b.Property("ConvertPrice")
+ .HasColumnType("float");
+
+ b.Property("CreatedByUserId")
+ .HasColumnType("int");
+
+ b.Property("Currency")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("CurrencyRate")
+ .HasColumnType("float");
+
+ b.Property("DODate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("DONo")
+ .HasColumnType("longtext");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("EndWDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("InvoiceDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("InvoiceNo")
+ .HasColumnType("longtext");
+
+ b.Property("ItemLocation")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ItemStatus")
+ .HasColumnType("int")
+ .HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
+
+ b.Property("PONo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("DefaultPrice")
+ .HasColumnType("float");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ b.Property("SerialNumber")
+ .HasColumnType("longtext");
+
+ b.Property("Supplier")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("TeamType")
+ .HasColumnType("longtext");
+
+ b.Property("UniqueID")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Warranty")
+ .HasColumnType("int");
+
+ b.HasKey("ItemID");
+
+ b.HasIndex("CompanyId");
+
+ b.HasIndex("CreatedByUserId");
+
+ b.HasIndex("DepartmentId");
+
+ b.HasIndex("ProductId");
+
+ b.ToTable("Items");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
+ {
+ b.Property("ManufacturerId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ManufacturerId"));
+
+ b.Property("ManufacturerName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("ManufacturerId");
+
+ b.ToTable("Manufacturers");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.Property("ProductId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProductId"));
+
+ b.Property("Category")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ImageProduct")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ManufacturerId")
+ .HasColumnType("int");
+
+ b.Property("ModelNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("QuantityProduct")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId");
+
+ b.HasIndex("ManufacturerId");
+
+ b.ToTable("Products");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
+ {
+ b.Property("SupplierId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SupplierId"));
+
+ b.Property("SupplierEmail")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierGender")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierName")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("SupplierPhoneNo")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("SupplierId");
+
+ b.ToTable("Suppliers");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
{
b.Property("CompanyId")
@@ -354,16 +533,16 @@ namespace PSTW_CentralSystem.Migrations
{
Id = 1,
AccessFailedCount = 0,
- ConcurrencyStamp = "f89f9499-14a5-4bba-a003-5bbb0ef1bb12",
+ ConcurrencyStamp = "7a7ee381-cecc-4268-9fc4-1f04eebfcb2c",
Email = "admin@pstw.com.my",
EmailConfirmed = true,
FullName = "MAAdmin",
LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY",
- PasswordHash = "AQAAAAIAAYagAAAAEDue4k8/8FwBvdJbbgBDLH+ibzmThXls6CmbJd99AdlrbPZrOWvWxlkv7cwVsPSM9g==",
+ PasswordHash = "AQAAAAIAAYagAAAAEKL4x2bfz8vXmcqMKqRsdQPdP9FVEhj4IR3FVvfFdeMdJb1Z7vekx6E3Qzycgpj3WA==",
PhoneNumberConfirmed = false,
- SecurityStamp = "d5684375-c368-409a-82e1-1e44fa05de60",
+ SecurityStamp = "5f7b5fe6-fb4d-4350-93aa-f3103c6e9a4d",
TwoFactorEnabled = false,
UserInfoStatus = 1,
UserName = "admin@pstw.com.my"
@@ -372,16 +551,16 @@ namespace PSTW_CentralSystem.Migrations
{
Id = 2,
AccessFailedCount = 0,
- ConcurrencyStamp = "d19f378c-eef5-4cf7-8ec6-c6b3904e4749",
+ ConcurrencyStamp = "fd4022cd-e08a-43c1-823c-573a86e86a9d",
Email = "sysadmin@pstw.com.my",
EmailConfirmed = true,
FullName = "SysAdmin",
LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
- PasswordHash = "AQAAAAIAAYagAAAAEDme/kiOHre+s0r9XvpwSr5dZIoWIbSJhI5B19mCjH4ZFoBBlF6Pay9WYJ2jcVZgfw==",
+ PasswordHash = "AQAAAAIAAYagAAAAENI+MWqt+OwSLiTBhOC5LBV7nWb8hnfcGEnUOLpadTdCHa6rV0ukUo6Hd5nGRL5rTw==",
PhoneNumberConfirmed = false,
- SecurityStamp = "7875eac4-323d-43cb-a083-940e52877171",
+ SecurityStamp = "0b4291c9-d818-4485-bd96-adde7e14286d",
TwoFactorEnabled = false,
UserInfoStatus = 1,
UserName = "sysadmin@pstw.com.my"
@@ -439,6 +618,52 @@ namespace PSTW_CentralSystem.Migrations
.IsRequired();
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
+ {
+ b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
+ .WithMany()
+ .HasForeignKey("CompanyId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Models.UserModel", "CreatedBy")
+ .WithMany()
+ .HasForeignKey("CreatedByUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
+ .WithMany()
+ .HasForeignKey("DepartmentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
+ .WithMany("Items")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Company");
+
+ b.Navigation("CreatedBy");
+
+ b.Navigation("Department");
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
+ .WithMany()
+ .HasForeignKey("ManufacturerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manufacturer");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
{
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
@@ -459,6 +684,11 @@ namespace PSTW_CentralSystem.Migrations
b.Navigation("Department");
});
+ modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
+ {
+ b.Navigation("Items");
+ });
+
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
{
b.Navigation("Departments");
diff --git a/Migrations/InventoryDB/20241206071642_Initiate.Designer.cs b/Migrations/InventoryDB/20241206071642_Initiate.Designer.cs
deleted file mode 100644
index 288c958..0000000
--- a/Migrations/InventoryDB/20241206071642_Initiate.Designer.cs
+++ /dev/null
@@ -1,394 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using PSTW_CentralSystem.DBContext;
-
-#nullable disable
-
-namespace PSTW_CentralSystem.Migrations.InventoryDB
-{
- [DbContext(typeof(InventoryDBContext))]
- [Migration("20241206071642_Initiate")]
- partial class Initiate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.11")
- .HasAnnotation("Relational:MaxIdentifierLength", 64);
-
- MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
-
- modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
- {
- b.Property("ItemID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID"));
-
- b.Property("CompanyId")
- .HasColumnType("int");
-
- b.Property("ConvertPrice")
- .HasColumnType("float");
-
- b.Property("CreatedByUserId")
- .HasColumnType("int");
-
- b.Property("Currency")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("CurrencyRate")
- .HasColumnType("float");
-
- b.Property("DODate")
- .HasColumnType("datetime(6)");
-
- b.Property("DONo")
- .HasColumnType("longtext");
-
- b.Property("DepartmentId")
- .HasColumnType("int");
-
- b.Property("EndWDate")
- .HasColumnType("datetime(6)");
-
- b.Property("InvoiceDate")
- .HasColumnType("datetime(6)");
-
- b.Property("InvoiceNo")
- .HasColumnType("longtext");
-
- b.Property("ItemLocation")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("ItemStatus")
- .HasColumnType("int")
- .HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
-
- b.Property("PONo")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("PriceInRM")
- .HasColumnType("float");
-
- b.Property("ProductId")
- .HasColumnType("int");
-
- b.Property("PurchaseDate")
- .HasColumnType("datetime(6)");
-
- b.Property("Quantity")
- .HasColumnType("int");
-
- b.Property("SerialNumber")
- .HasColumnType("longtext");
-
- b.Property("Supplier")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("TeamType")
- .HasColumnType("longtext");
-
- b.Property("UniqueID")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("Warranty")
- .HasColumnType("int");
-
- b.HasKey("ItemID");
-
- b.HasIndex("CompanyId");
-
- b.HasIndex("CreatedByUserId");
-
- b.HasIndex("DepartmentId");
-
- b.HasIndex("ProductId");
-
- b.ToTable("Items");
- });
-
- modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
- {
- b.Property("ManufacturerId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ManufacturerId"));
-
- b.Property("ManufacturerName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("ManufacturerId");
-
- b.ToTable("Manufacturers");
- });
-
- modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
- {
- b.Property("ProductId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProductId"));
-
- b.Property("Category")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("ImageProduct")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("ManufacturerId")
- .HasColumnType("int");
-
- b.Property("ModelNo")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("ProductName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("QuantityProduct")
- .HasColumnType("int");
-
- b.HasKey("ProductId");
-
- b.HasIndex("ManufacturerId");
-
- b.ToTable("Products");
- });
-
- modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
- {
- b.Property("SupplierId")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SupplierId"));
-
- b.Property("SupplierEmail")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("SupplierGender")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property