This commit is contained in:
MOHD ARIFF 2024-12-05 16:11:52 +08:00
parent 391a359a9f
commit 8135725180
27 changed files with 316 additions and 2624 deletions

View File

@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using PSTW_CentralSystem.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
namespace PSTW_CentralSystem.Areas.Inventory.Controllers namespace PSTW_CentralSystem.Areas.Inventory.Controllers
{ {
@ -9,44 +12,69 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
//[Authorize(Policy = "RoleModulePolicy")] //[Authorize(Policy = "RoleModulePolicy")]
public class ItemController : Controller public class ItemController : Controller
{ {
private readonly IHttpContextAccessor _httpContextAccessor;
public ItemController(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string GetCurrentUserId()
{
var user = _httpContextAccessor.HttpContext?.User;
if (user == null)
{
return null!;
}
return user.FindFirstValue(ClaimTypes.NameIdentifier) ?? null!; // Returns the user ID
}
// GET: Inventory // GET: Inventory
public ActionResult Index() public ActionResult Index()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
public IActionResult ItemRegistration() public IActionResult ItemRegistration()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
public IActionResult ProductRegistration() public IActionResult ProductRegistration()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Details/5 // GET: Inventory/Details/5
public ActionResult Details(int id) public ActionResult Details(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Create // GET: Inventory/Create
public ActionResult Create() public ActionResult Create()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Edit/5 // GET: Inventory/Edit/5
public ActionResult Edit(int id) public ActionResult Edit(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Delete/5 // GET: Inventory/Delete/5
public ActionResult Delete(int id) public ActionResult Delete(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
} }

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
namespace PSTW_CentralSystem.Areas.Inventory.Controllers namespace PSTW_CentralSystem.Areas.Inventory.Controllers
{ {
@ -8,43 +9,68 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
//[Authorize(Policy = "RoleModulePolicy")] //[Authorize(Policy = "RoleModulePolicy")]
public class MainController : Controller public class MainController : Controller
{ {
private readonly IHttpContextAccessor _httpContextAccessor;
public MainController(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string GetCurrentUserId()
{
var user = _httpContextAccessor.HttpContext?.User;
if (user == null)
{
return null!;
}
return user.FindFirstValue(ClaimTypes.NameIdentifier) ?? null!; // Returns the user ID
}
// GET: Inventory // GET: Inventory
public ActionResult Index() public ActionResult Index()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
public IActionResult SupplierRegistration() public IActionResult SupplierRegistration()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
public IActionResult ManifacturerRegistration() public IActionResult ManifacturerRegistration()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Details/5 // GET: Inventory/Details/5
public ActionResult Details(int id) public ActionResult Details(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Create // GET: Inventory/Create
public ActionResult Create() public ActionResult Create()
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Edit/5 // GET: Inventory/Edit/5
public ActionResult Edit(int id) public ActionResult Edit(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
// GET: Inventory/Delete/5 // GET: Inventory/Delete/5
public ActionResult Delete(int id) public ActionResult Delete(int id)
{ {
return View(); var userId = GetCurrentUserId();
return View(userId);
} }
} }

View File

@ -1,5 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using PSTW_CentralSystem.Models;
namespace PSTW_CentralSystem.Areas.Inventory.Models namespace PSTW_CentralSystem.Areas.Inventory.Models
{ {
@ -12,6 +15,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public required int DepartmentId { get; set; } public required int DepartmentId { get; set; }
public required int ProductId { get; set; } public required int ProductId { get; set; }
public required string? SerialNumber { get; set; } public required string? SerialNumber { get; set; }
public required string? TeamType { get; set; }
public required int Quantity { get; set; } public required int Quantity { get; set; }
public required string Supplier { get; set; } public required string Supplier { get; set; }
public required DateTime PurchaseDate { get; set; } public required DateTime PurchaseDate { get; set; }
@ -20,10 +24,19 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public required float PriceInRM { get; set; } public required float PriceInRM { get; set; }
public required float CurrencyRate { get; set; } public required float CurrencyRate { get; set; }
public required float ConvertPrice { get; set; } public required float ConvertPrice { get; set; }
public required DateTime DODate { get; set; } public string? DONo { get; set; }
public DateTime? DODate { get; set; }
public required int Warranty { get; set; } public required int Warranty { get; set; }
public required DateTime EndWDate { get; set; } public required DateTime EndWDate { get; set; }
public required DateTime InvoiceDate { get; set; } public string? InvoiceNo { get; set; }
public DateTime? InvoiceDate { get; set; }
[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;")]
public int ItemStatus { get; set; } = 1;
public string ItemLocation { get; set; } = string.Empty;
public int CreatedByUserId { get; set; }
[ForeignKey("CreatedByUserId")]
public virtual UserModel? CreatedBy { get; set; }
[ForeignKey("CompanyId")] [ForeignKey("CompanyId")]
public virtual CompanyModel? Company { get; set; } public virtual CompanyModel? Company { get; set; }
[ForeignKey("DepartmentId")] [ForeignKey("DepartmentId")]

View File

@ -0,0 +1,6 @@
namespace PSTW_CentralSystem.Areas.Inventory.Models
{
public class StoreModel
{
}
}

View File

@ -2,8 +2,9 @@
@{ @{
ViewData["Title"] = "Item Form"; ViewData["Title"] = "Item Form";
Layout = "~/Views/Shared/_Layout.cshtml"; Layout = "~/Views/Shared/_Layout.cshtml";
string userId = ViewBag.UserId;
} }
<style> <style>
.table td img { .table td img {
display: block !important; display: block !important;
@ -66,7 +67,7 @@
<label class="col-sm-4 col-form-label">Company:</label> <label class="col-sm-4 col-form-label">Company:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="dropdown"> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle" v-model="selectedCompany" required> <select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedCompany" required>
<option class="btn-light" value="" disabled selected>Select Company</option> <option class="btn-light" value="" disabled selected>Select Company</option>
<option class="btn-light" v-for="(item, index) in companies" :key="index" :value="item.companyId">{{item.companyName}}</option> <option class="btn-light" v-for="(item, index) in companies" :key="index" :value="item.companyId">{{item.companyName}}</option>
</select> </select>
@ -78,20 +79,31 @@
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Department:</label> <label class="col-sm-4 col-form-label">Department:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle" v-model="selectedDepartment" required> <select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedDepartment" required>
<option class="btn-light" value="" disabled selected>Select Department</option> <option class="btn-light" value="" disabled selected>Select Department</option>
<option class="btn-light" v-for="(dept, index) in filteredDepartments" :key="index" :value="dept.departmentId">{{ dept.departmentName }}</option> <option class="btn-light" v-for="(dept, index) in filteredDepartments" :key="index" :value="dept.departmentId">{{ dept.departmentName }}</option>
</select> </select>
</div> </div>
</div> </div>
<!-- TeamType Dropdown -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Team:</label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="teamType" required>
<option class="btn-light" value="" disabled selected>Select Team</option>
<option class="btn-light" v-for="(team, index) in teamTypes" :key="index" :value="team">{{ team }}</option>
</select>
</div>
</div>
@* Product Name Coding *@ @* Product Name Coding *@
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-4 col-form-label">Product Name:</label> <label class="col-sm-4 col-form-label">Product Name:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="dropdown"> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle" v-model="selectedProduct" required> <select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedProduct" required>
<option class="btn-light" value="" disabled selected>Select Product</option> <option class="btn-light" value="" disabled selected>Select Product</option>
<option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId">{{ item.productName + ' (' + item.modelNo + ')' }}</option> <option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId">{{ item.productName + ' (' + item.modelNo + ')' }}</option>
</select> </select>
@ -164,7 +176,7 @@
<label class="col-sm-4 col-form-label">Supplier: </label> <label class="col-sm-4 col-form-label">Supplier: </label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="dropdown"> <div class="dropdown">
<select class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" v-model="selectedSupplier" required> <select class="btn btn-primary dropdown-toggle col-md-10" data-toggle="dropdown" aria-expanded="false" v-model="selectedSupplier" required>
<option class="btn-light" value="" disabled selected>Select Supplier</option> <option class="btn-light" value="" disabled selected>Select Supplier</option>
<option class="btn-light" v-for="(item, index) in suppliers">{{ item.supplierName }}</option> <option class="btn-light" v-for="(item, index) in suppliers">{{ item.supplierName }}</option>
</select> </select>
@ -192,9 +204,9 @@
<div class="col-md-6"> <div class="col-md-6">
@* Item Price in RM *@ @* Item Price in RM *@
<div class="form-group row"> <div class="form-group row">
<label for="priceInRM" class="col-sm-4">Item Price In(RM):</label> <label for="priceInRM" class="col-sm-4">Default Item Price:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" id="priceInRM" name="priceInRM" class="form-control" placeholder="RM 00.00" step="0.01" v-on:input="convertCurrency()" required v-model="priceInRM"> <input type="number" id="priceInRM" name="priceInRM" class="form-control" placeholder="RM 00.00" step="0.01" min="0.01" v-on:input="convertCurrency()" required v-model="priceInRM">
</div> </div>
</div> </div>
@ -202,9 +214,9 @@
<div class="form-group row"> <div class="form-group row">
<label for="currency" class="col-sm-4">Select Currency:</label> <label for="currency" class="col-sm-4">Select Currency:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select id="currency" name="currency" class="form-control" v-model="currency" v-on:change="convertCurrency()"> <select id="currency" name="currency" class="btn btn-primary form-control col-md-10" v-model="currency" v-on:change="convertCurrency()">
<option value="" disabled selected>Select a currency</option> <option class="btn-light" value="" disabled selected>Select a currency</option>
<option v-for="(name, code) in currencies" :key="code" :value="code"> <option class="btn-light" v-for="(name, code) in currencies" :key="code" :value="code">
{{ code }} - {{ name }} {{ code }} - {{ name }}
</option> </option>
</select> </select>
@ -215,7 +227,7 @@
<div class="form-group row"> <div class="form-group row">
<label for="currencyRate" class="col-sm-4">Currency Rate(%):</label> <label for="currencyRate" class="col-sm-4">Currency Rate(%):</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" id="currencyRate" name="currencyRate" class="form-control" placeholder="0.01%" step="0.01" v-on:input="convertCurrency()" required v-model="currencyRate"> <input type="number" id="currencyRate" name="currencyRate" class="form-control" placeholder="0.01" step="0.01" min="1" v-on:input="convertCurrency()" required v-model="currencyRate">
</div> </div>
</div> </div>
@ -227,17 +239,25 @@
</div> </div>
</div> </div>
@* Delivery Order Number *@
<div class="form-group row">
<label for="DONo" class="col-sm-4">Enter DO Number:</label>
<div class="col-sm-8">
<input type="text" id="DONo" name="DONo" class="form-control" v-model="DONo" placeholder="DO123456">
</div>
</div>
@* Delivery Order Date *@ @* Delivery Order Date *@
<div class="form-group row"> <div class="form-group row">
<label for="DODate" class="col-sm-4">Enter DO Date:</label> <label for="DODate" class="col-sm-4">Enter DO Date:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" required v-model="DODate"> <input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" v-model="DODate">
</div> </div>
</div> </div>
@* Warranty *@ @* Warranty *@
<div class="form-group row"> <div class="form-group row">
<label for="warranty" class="col-sm-4">Enter Warranty Months(Number):</label> <label for="warranty" class="col-sm-4">Enter Warranty (Months):</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" required v-model="warranty"> <input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" required v-model="warranty">
</div> </div>
@ -251,11 +271,19 @@
</div> </div>
</div> </div>
@* Invoice Number *@
<div class="form-group row">
<label for="invoiceNo" class="col-sm-4">Invoice Number:</label>
<div class="col-sm-8">
<input type="text" id="invoiceNo" name="invoiceNo" class="form-control" v-model="invoiceNo" placeholder="Invoice123456">
</div>
</div>
@* Invoice Date *@ @* Invoice Date *@
<div class="form-group row"> <div class="form-group row">
<label for="invoiceDate" class="col-sm-4">Invoice Date:</label> <label for="invoiceDate" class="col-sm-4">Invoice Date:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="date" id="invoiceDate" name="invoiceDate" class="form-control" required v-model="invoiceDate"> <input type="date" id="invoiceDate" name="invoiceDate" class="form-control" v-model="invoiceDate">
</div> </div>
</div> </div>
@ -318,6 +346,8 @@
], ],
company: "", company: "",
Dept: null, Dept: null,
teamTypes: ["Continuous", "Manual"],
teamType: "",
productName: null, productName: null,
imageProduct: null, imageProduct: null,
productCategory: null, productCategory: null,
@ -326,13 +356,15 @@
supplierName: null, supplierName: null,
purchaseDate: null, purchaseDate: null,
PO: null, PO: null,
currency: null, currency: "MYR",
priceInRM: null, priceInRM: 0.01,
currencyRate: 1, currencyRate: 1,
convertPrice: 0, convertPrice: 0,
DONo:null,
DODate: null, DODate: null,
warranty: 0, warranty: 0,
EndWDate: null, EndWDate: null,
invoiceNo: null,
invoiceDate: null, invoiceDate: null,
products: [], products: [],
depts: [], depts: [],
@ -691,12 +723,12 @@
//----------------------// //----------------------//
//Calculate Total Price //Calculate Total Price
convertCurrency() { convertCurrency() {
const total = this.priceInRM / this.currencyRate; const total = this.priceInRM * this.currencyRate;
this.convertPrice = total.toFixed(2); this.convertPrice = total.toFixed(2);
this.priceInRM = this.priceInRM this.priceInRM = this.priceInRM
.replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points // .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points
.replace(/(\..*)\..*/g, '$1') // Allow only one decimal point // .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point
.replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places // .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places
}, },
calculateWarrantyEndDate() { calculateWarrantyEndDate() {

View File

@ -1,6 +1,7 @@
@{ @{
ViewData["Title"] = "Product Form"; ViewData["Title"] = "Product Form";
Layout = "~/Views/Shared/_Layout.cshtml"; Layout = "~/Views/Shared/_Layout.cshtml";
string userId = ViewBag.UserId;
} }
@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); @await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml");

View File

@ -10,9 +10,9 @@ namespace PSTW_CentralSystem.Controllers.API
public class AdminAPI : Controller public class AdminAPI : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly AuthDBContext _authDbContext; private readonly IdentityDBContext _authDbContext;
public AdminAPI(ILogger<HomeController> logger, AuthDBContext authDbContext) public AdminAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
{ {
_logger = logger; _logger = logger;
_authDbContext = authDbContext; _authDbContext = authDbContext;

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PSTW_CentralSystem.DBContext;
namespace PSTW_CentralSystem.Controllers.API
{
[ApiController]
[Route("[controller]")]
public class IdentityAPI : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IdentityDBContext _authDbContext;
public IdentityAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
{
_logger = logger;
_authDbContext = authDbContext;
}
[HttpPost("GetUserInformation/{id}")]
public async Task<IActionResult> GetModuleInformation(int id)
{
var userInfo = await _authDbContext.Users.Where(x => x.Id == id).FirstOrDefaultAsync();
return Json("userInfo");
}
}
}

View File

@ -18,12 +18,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public class InvMainAPI : Controller public class InvMainAPI : Controller
{ {
private readonly ILogger<InvMainAPI> _logger; private readonly ILogger<InvMainAPI> _logger;
private readonly AuthDBContext _authDbContext; private readonly IdentityDBContext _identityDbContext;
private readonly InventoryDBContext _inventoryDbContext;
public InvMainAPI(ILogger<InvMainAPI> logger, AuthDBContext authDbContext) public InvMainAPI(ILogger<InvMainAPI> logger, IdentityDBContext authDbContext, InventoryDBContext inventoryDbContext)
{ {
_logger = logger; _logger = logger;
_authDbContext = authDbContext; _identityDbContext = authDbContext;
_inventoryDbContext = inventoryDbContext;
} }
public class DepartmentCompany public class DepartmentCompany
@ -36,8 +38,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public async Task<List<DepartmentCompany>> GetDepartmentWithCompanyList() public async Task<List<DepartmentCompany>> GetDepartmentWithCompanyList()
{ {
var departmentList = await _authDbContext.Departments.ToListAsync(); var departmentList = await _identityDbContext.Departments.ToListAsync();
var companyList = await _authDbContext.Companies.ToListAsync(); var companyList = await _identityDbContext.Companies.ToListAsync();
// Create a new list to store departments with their company name // Create a new list to store departments with their company name
var departmentWithCompanyList = departmentList.Select(department => new DepartmentCompany var departmentWithCompanyList = departmentList.Select(department => new DepartmentCompany
@ -53,13 +55,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
} }
public async Task<DepartmentCompany> GetDepartmentWithCompany(int companyId, int departmentId) public async Task<DepartmentCompany> GetDepartmentWithCompany(int companyId, int departmentId)
{ {
var departmentList = await _authDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId ); var departmentList = await _identityDbContext.Departments.FirstOrDefaultAsync(d => d.DepartmentId == departmentId );
var companyList = await _authDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId); var companyList = await _identityDbContext.Companies.FirstOrDefaultAsync(c => c.CompanyId == companyId);
// Create a new list to store departments with their company name // Create a new list to store departments with their company name
var departmentWithCompany = new DepartmentCompany var departmentWithCompany = new DepartmentCompany
{ {
DepartmentId = departmentList.DepartmentId, DepartmentId = departmentList!.DepartmentId,
DepartmentName = departmentList.DepartmentName, DepartmentName = departmentList.DepartmentName,
CompanyId = departmentList.CompanyId, CompanyId = departmentList.CompanyId,
CompanyName = companyList?.CompanyName CompanyName = companyList?.CompanyName
@ -74,7 +76,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ManufacturerList")] [HttpPost("ManufacturerList")]
public async Task<IActionResult> ManufacturerList() public async Task<IActionResult> ManufacturerList()
{ {
var manifacturerList = await _authDbContext.Manufacturers.ToListAsync(); var manifacturerList = await _inventoryDbContext.Manufacturers.ToListAsync();
return Json(manifacturerList); return Json(manifacturerList);
} }
@ -92,12 +94,12 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try try
{ {
_authDbContext.Manufacturers.Add(new ManufacturerModel _inventoryDbContext.Manufacturers.Add(new ManufacturerModel
{ {
ManufacturerName = manufacturer.ManufacturerName, ManufacturerName = manufacturer.ManufacturerName,
}); });
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
var updatedList = await _authDbContext.Manufacturers.ToListAsync(); var updatedList = await _inventoryDbContext.Manufacturers.ToListAsync();
return Json(updatedList); return Json(updatedList);
} }
catch (Exception ex) catch (Exception ex)
@ -109,14 +111,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteManufacturer/{id}")] [HttpDelete("DeleteManufacturer/{id}")]
public async Task<IActionResult> DeleteManufacturer(int id) public async Task<IActionResult> DeleteManufacturer(int id)
{ {
var manufacturer = await _authDbContext.Manufacturers.FindAsync(id); var manufacturer = await _inventoryDbContext.Manufacturers.FindAsync(id);
if (manufacturer == null) if (manufacturer == null)
{ {
return NotFound(new { success = false, message = "Manufacturer not found" }); return NotFound(new { success = false, message = "Manufacturer not found" });
} }
_authDbContext.Manufacturers.Remove(manufacturer); _inventoryDbContext.Manufacturers.Remove(manufacturer);
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Manufacturer deleted successfully" }); return Ok(new { success = true, message = "Manufacturer deleted successfully" });
} }
@ -128,14 +130,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ProductList")] [HttpPost("ProductList")]
public async Task<IActionResult> ProductList() public async Task<IActionResult> ProductList()
{ {
var productList = await _authDbContext.Products.Include("Manufacturer").ToListAsync(); var productList = await _inventoryDbContext.Products.Include("Manufacturer").ToListAsync();
return Json(productList); return Json(productList);
} }
[HttpPost("ProductListWithItem")] [HttpPost("ProductListWithItem")]
public async Task<IActionResult> ProductListWithItem() public async Task<IActionResult> ProductListWithItem()
{ {
var productList = await _authDbContext.Products var productList = await _inventoryDbContext.Products
.Include(p => p.Items) // Include related items .Include(p => p.Items) // Include related items
.Include(p => p.Manufacturer) // Include related manufacturer .Include(p => p.Manufacturer) // Include related manufacturer
.ToListAsync(); .ToListAsync();
@ -167,9 +169,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
await System.IO.File.WriteAllBytesAsync(filePath, bytes); await System.IO.File.WriteAllBytesAsync(filePath, bytes);
product.ImageProduct = "/media/inventory/images/" + product.ModelNo + ".jpg"; product.ImageProduct = "/media/inventory/images/" + product.ModelNo + ".jpg";
} }
_authDbContext.Products.Add(product); _inventoryDbContext.Products.Add(product);
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
var updatedList = await _authDbContext.Products.Include("Manufacturer").Where(x => x.ManufacturerId == x.ManufacturerId).ToListAsync(); var updatedList = await _inventoryDbContext.Products.Include("Manufacturer").Where(x => x.ManufacturerId == x.ManufacturerId).ToListAsync();
return Json(updatedList); return Json(updatedList);
} }
catch (Exception ex) catch (Exception ex)
@ -181,14 +183,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteProduct/{id}")] [HttpDelete("DeleteProduct/{id}")]
public async Task<IActionResult> DeleteProduct(int id) public async Task<IActionResult> DeleteProduct(int id)
{ {
var Product = await _authDbContext.Products.FindAsync(id); var Product = await _inventoryDbContext.Products.FindAsync(id);
if (Product == null) if (Product == null)
{ {
return NotFound(new { success = false, message = "Product not found" }); return NotFound(new { success = false, message = "Product not found" });
} }
_authDbContext.Products.Remove(Product); _inventoryDbContext.Products.Remove(Product);
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Product deleted successfully" }); return Ok(new { success = true, message = "Product deleted successfully" });
} }
@ -200,7 +202,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("CompanyDepartmentList")] [HttpPost("CompanyDepartmentList")]
public async Task<IActionResult> CompanyDepartmentList() public async Task<IActionResult> CompanyDepartmentList()
{ {
var companyList = await _authDbContext.Companies var companyList = await _identityDbContext.Companies
.Include(c => c.Departments) .Include(c => c.Departments)
.Select(c => new { c.CompanyId, c.CompanyName, Departments = c.Departments .Select(c => new { c.CompanyId, c.CompanyName, Departments = c.Departments
.OrderBy(d => d.DepartmentId) .OrderBy(d => d.DepartmentId)
@ -217,7 +219,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("DepartmentCompanyList")] [HttpPost("DepartmentCompanyList")]
public async Task<IActionResult> DepartmentCompanyList() public async Task<IActionResult> DepartmentCompanyList()
{ {
var itemDepartment = await _authDbContext.Departments var itemDepartment = await _identityDbContext.Departments
.Include(d => d.Company) // Include the related Company entity .Include(d => d.Company) // Include the related Company entity
.Select(d => new .Select(d => new
{ {
@ -239,7 +241,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("SupplierList")] [HttpPost("SupplierList")]
public async Task<IActionResult> SupplierList() public async Task<IActionResult> SupplierList()
{ {
var supplierList = await _authDbContext.Suppliers.ToListAsync(); var supplierList = await _inventoryDbContext.Suppliers.ToListAsync();
return Json(supplierList); return Json(supplierList);
} }
@ -250,7 +252,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("ItemList")] [HttpPost("ItemList")]
public async Task<IActionResult> ItemList() public async Task<IActionResult> ItemList()
{ {
var itemList = await _authDbContext.Items.ToListAsync(); var itemList = await _inventoryDbContext.Items.ToListAsync();
// Retrieve the request's host and scheme // Retrieve the request's host and scheme
var request = HttpContext.Request; var request = HttpContext.Request;
string domain = $"{request.Scheme}://{request.Host.Value}"; string domain = $"{request.Scheme}://{request.Host.Value}";
@ -305,7 +307,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try try
{ {
var product = await _authDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found"); var product = await _inventoryDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found");
var addToProduct = item.Quantity; var addToProduct = item.Quantity;
product.QuantityProduct += addToProduct; product.QuantityProduct += addToProduct;
@ -315,17 +317,17 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.SerialNumber = null; item.SerialNumber = null;
} }
_authDbContext.Items.Add(item); _inventoryDbContext.Items.Add(item);
_authDbContext.Products.Update(product); _inventoryDbContext.Products.Update(product);
await _authDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID await _identityDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID
// Fetch the generated ItemID // Fetch the generated ItemID
var savedItem = await _authDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID); var savedItem = await _inventoryDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID);
if (savedItem != null) if (savedItem != null)
{ {
var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId); var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId);
var itemProduct = _authDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault(); var itemProduct = _inventoryDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault();
string? companyInitial = companyDepartment!.CompanyName?.ToString().Substring(0, 1).ToUpper(); string? companyInitial = companyDepartment!.CompanyName?.ToString().Substring(0, 1).ToUpper();
string? departmentInitial = companyDepartment!.DepartmentName?.ToString().Substring(0, 1).ToUpper(); string? departmentInitial = companyDepartment!.DepartmentName?.ToString().Substring(0, 1).ToUpper();
@ -335,8 +337,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var uniqueId = $"{companyInitial}{departmentInitial}{initialCategory}{productId}{itemId}".ToUpper(); var uniqueId = $"{companyInitial}{departmentInitial}{initialCategory}{productId}{itemId}".ToUpper();
savedItem.UniqueID = uniqueId; savedItem.UniqueID = uniqueId;
_authDbContext.Items.Update(savedItem); _inventoryDbContext.Items.Update(savedItem);
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
} }
var updatedItem = new var updatedItem = new
{ {
@ -370,14 +372,14 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpDelete("DeleteItem/{id}")] [HttpDelete("DeleteItem/{id}")]
public async Task<IActionResult> DeleteItem(int id) public async Task<IActionResult> DeleteItem(int id)
{ {
var item = await _authDbContext.Items.FindAsync(id); var item = await _inventoryDbContext.Items.FindAsync(id);
if (item == null) if (item == null)
{ {
return NotFound(new { success = false, message = "Item not found" }); return NotFound(new { success = false, message = "Item not found" });
} }
_authDbContext.Items.Remove(item); _inventoryDbContext.Items.Remove(item);
await _authDbContext.SaveChangesAsync(); await _identityDbContext.SaveChangesAsync();
return Ok(new { success = true, message = "Item deleted successfully" }); return Ok(new { success = true, message = "Item deleted successfully" });
} }

View File

@ -11,8 +11,8 @@ namespace PSTW_CentralSystem.Controllers.API
public class ModuleAPI : Controller public class ModuleAPI : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly AuthDBContext _authDbContext; private readonly IdentityDBContext _authDbContext;
public ModuleAPI(ILogger<HomeController> logger, AuthDBContext authDbContext) public ModuleAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
{ {
_logger = logger; _logger = logger;
_authDbContext = authDbContext; _authDbContext = authDbContext;

View File

@ -10,9 +10,9 @@ namespace PSTW_CentralSystem.Controllers.API
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly AuthDBContext _authDbContext; private readonly IdentityDBContext _authDbContext;
public RoleAPI(ILogger<HomeController> logger, AuthDBContext authDbContext) public RoleAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
{ {
_logger = logger; _logger = logger;
_authDbContext = authDbContext; _authDbContext = authDbContext;

View File

@ -9,10 +9,10 @@ namespace PSTW_CentralSystem.Controllers
//[Authorize(Policy = "RoleModulePolicy")] //[Authorize(Policy = "RoleModulePolicy")]
public class AdminController : Controller public class AdminController : Controller
{ {
private readonly AuthDBContext _authDbContext; private readonly IdentityDBContext _authDbContext;
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
public AdminController(ILogger<HomeController> logger, AuthDBContext authDbContext) public AdminController(ILogger<HomeController> logger, IdentityDBContext authDbContext)
{ {
_logger = logger; _logger = logger;
_authDbContext = authDbContext; _authDbContext = authDbContext;

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace PSTW_CentralSystem.Views.JSA namespace PSTW_CentralSystem.Controllers.JSA
{ {
public class JSAController : Controller public class JSAController : Controller
{ {

View File

@ -14,11 +14,11 @@ namespace PSTW_CentralSystem.CustomPolicy
} }
public class RoleModuleHandler : AuthorizationHandler<RoleModulePolicy> public class RoleModuleHandler : AuthorizationHandler<RoleModulePolicy>
{ {
private readonly AuthDBContext _authDBContext; private readonly IdentityDBContext _authDBContext;
private readonly UserManager<UserModel> _userManager; private readonly UserManager<UserModel> _userManager;
private readonly RoleManager<RoleModel> _roleManager; private readonly RoleManager<RoleModel> _roleManager;
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;
public RoleModuleHandler( AuthDBContext authDBContext, UserManager<UserModel> userManager, RoleManager<RoleModel> roleManager, IHttpContextAccessor httpContextAccessor) public RoleModuleHandler( IdentityDBContext authDBContext, UserManager<UserModel> userManager, RoleManager<RoleModel> roleManager, IHttpContextAccessor httpContextAccessor)
{ {
_authDBContext = authDBContext; _authDBContext = authDBContext;
_userManager = userManager; _userManager = userManager;

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Newtonsoft.Json; using Newtonsoft.Json;
using PSTW_CentralSystem.Areas.Inventory.Models; using PSTW_CentralSystem.Areas.Inventory.Models;
using PSTW_CentralSystem.Models; using PSTW_CentralSystem.Models;
@ -8,10 +9,10 @@ using System.Text.Json;
namespace PSTW_CentralSystem.DBContext namespace PSTW_CentralSystem.DBContext
{ {
public class AuthDBContext : IdentityDbContext<UserModel, RoleModel, int> public class IdentityDBContext : IdentityDbContext<UserModel, RoleModel, int>
{ {
private readonly IWebHostEnvironment _hostingEnvironment; private readonly IWebHostEnvironment _hostingEnvironment;
public AuthDBContext(DbContextOptions<AuthDBContext> options, IWebHostEnvironment hostingEnvironment) : base(options) public IdentityDBContext(DbContextOptions<IdentityDBContext> options, IWebHostEnvironment hostingEnvironment) : base(options)
{ {
_hostingEnvironment = hostingEnvironment; _hostingEnvironment = hostingEnvironment;
} }
@ -24,7 +25,13 @@ namespace PSTW_CentralSystem.DBContext
.Property(e => e.MethodAllowedUserType) .Property(e => e.MethodAllowedUserType)
.HasConversion( .HasConversion(
v => JsonConvert.SerializeObject(v), // Convert List<MethodAllowedUserType> to JSON string v => JsonConvert.SerializeObject(v), // Convert List<MethodAllowedUserType> to JSON string
v => JsonConvert.DeserializeObject<List<MethodAllowedUserType>>(v)); v => JsonConvert.DeserializeObject<List<MethodAllowedUserType>>(v))
.Metadata.SetValueComparer(
new ValueComparer<List<MethodAllowedUserType>>(
(c1, c2) => c1 != null && c2 != null && c1.SequenceEqual(c2), // Compare two lists
c => c != null ? c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())) : 0, // HashCode
c => c != null ? c.ToList() : null // Clone the list to avoid mutations
));
// Seeding Roles // Seeding Roles
modelBuilder.Entity<RoleModel>().HasData( modelBuilder.Entity<RoleModel>().HasData(
@ -67,6 +74,10 @@ namespace PSTW_CentralSystem.DBContext
// Seeding AdminRole // Seeding AdminRole
modelBuilder.Entity<IdentityUserRole<int>>().HasData( modelBuilder.Entity<IdentityUserRole<int>>().HasData(
new IdentityUserRole<int> { UserId = 1, RoleId = 1 }); new IdentityUserRole<int> { UserId = 1, RoleId = 1 });
// Seeding SystemAdminRole
modelBuilder.Entity<IdentityUserRole<int>>().HasData(
new IdentityUserRole<int> { UserId = 2, RoleId = 2 });
} }
public new DbSet<UserModel> Users { get; set; } public new DbSet<UserModel> Users { get; set; }
@ -74,10 +85,6 @@ namespace PSTW_CentralSystem.DBContext
public DbSet<ModuleSettingModel> ModuleSettings { get; set; } public DbSet<ModuleSettingModel> ModuleSettings { get; set; }
public DbSet<CompanyModel> Companies { get; set; } public DbSet<CompanyModel> Companies { get; set; }
public DbSet<DepartmentModel> Departments { get; set; } public DbSet<DepartmentModel> Departments { get; set; }
public DbSet<ManufacturerModel> Manufacturers { get; set; }
public DbSet<ItemModel> Items { get; set; }
public DbSet<ProductModel> Products{ get; set; }
public DbSet<SupplierModel> Suppliers{ get; set; }
} }
} }

View File

@ -0,0 +1,28 @@
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<InventoryDBContext> options, IWebHostEnvironment hostingEnvironment) : base(options)
{
_hostingEnvironment = hostingEnvironment;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
public DbSet<ManufacturerModel> Manufacturers { get; set; }
public DbSet<ItemModel> Items { get; set; }
public DbSet<ProductModel> Products { get; set; }
public DbSet<SupplierModel> Suppliers { get; set; }
}
}

View File

@ -1,648 +0,0 @@
// <auto-generated />
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
{
[DbContext(typeof(AuthDBContext))]
[Migration("20241128045608_Initiate")]
partial class Initiate
{
/// <inheritdoc />
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("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
b.HasData(
new
{
UserId = 1,
RoleId = 1
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", b =>
{
b.Property<int>("CompanyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("CompanyId"));
b.Property<string>("CompanyName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("CompanyId");
b.ToTable("Companies");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.Property<int>("DepartmentId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("DepartmentId"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<string>("DepartmentName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("DepartmentId");
b.HasIndex("CompanyId");
b.ToTable("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.Property<int>("ItemID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ItemID"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<float>("ConvertPrice")
.HasColumnType("float");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("CurrencyRate")
.HasColumnType("float");
b.Property<DateTime>("DODate")
.HasColumnType("datetime(6)");
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<DateTime>("EndWDate")
.HasColumnType("datetime(6)");
b.Property<DateTime>("InvoiceDate")
.HasColumnType("datetime(6)");
b.Property<string>("PONo")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("PriceInRM")
.HasColumnType("float");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<DateTime>("PurchaseDate")
.HasColumnType("datetime(6)");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<string>("SerialNumber")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Supplier")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("UniqueID")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Warranty")
.HasColumnType("int");
b.HasKey("ItemID");
b.HasIndex("CompanyId");
b.HasIndex("DepartmentId");
b.HasIndex("ProductId");
b.ToTable("Items");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
{
b.Property<int>("ManufacturerId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ManufacturerId"));
b.Property<string>("ManufacturerName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("ManufacturerId");
b.ToTable("Manufacturers");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Property<int>("ProductId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ProductId"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ImageProduct")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("ManufacturerId")
.HasColumnType("int");
b.Property<string>("ModelNo")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("QuantityProduct")
.HasColumnType("int");
b.HasKey("ProductId");
b.HasIndex("ManufacturerId");
b.ToTable("Products");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SupplierId"));
b.Property<string>("SupplierEmail")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierGender")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierPhoneNo")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("SupplierId");
b.ToTable("Suppliers");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b =>
{
b.Property<int>("SettingId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SettingId"));
b.Property<string>("AllowedUserType")
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("MethodAllowedUserType")
.HasColumnType("json");
b.Property<string>("ModuleName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("ModuleStatus")
.HasColumnType("int");
b.HasKey("SettingId");
b.ToTable("ModuleSettings");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = 1,
Description = "Can access all pages",
Name = "SuperAdmin",
NormalizedName = "SUPERADMIN"
},
new
{
Id = 2,
Description = "Can access some admin pages",
Name = "SystemAdmin",
NormalizedName = "SYSTEMADMIN"
},
new
{
Id = 3,
Description = "Can access operation pages",
Name = "Engineer",
NormalizedName = "ENGINEER"
},
new
{
Id = 4,
Description = "Can access data viewer pages",
Name = "Observer",
NormalizedName = "OBSERVER"
});
});
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("FullName")
.HasColumnType("longtext");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int?>("UserStatus")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
b.HasData(
new
{
Id = 1,
AccessFailedCount = 0,
ConcurrencyStamp = "df01136b-c869-4bc3-9512-34a9cdc8f73d",
Email = "admin@pstw.com.my",
EmailConfirmed = true,
FullName = "MAAdmin",
LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAECcU3fIsIpqE1gECPg262gMejQiypGUXipVbiRtF66ywBqUHdohCj89hiJAafOlrPQ==",
PhoneNumberConfirmed = false,
SecurityStamp = "d36451ff-cfab-46e1-bf80-6b428d79a19b",
TwoFactorEnabled = false,
UserName = "admin@pstw.com.my"
},
new
{
Id = 2,
AccessFailedCount = 0,
ConcurrencyStamp = "6f7244cf-e611-4088-890a-72939cfbefa5",
Email = "sysadmin@pstw.com.my",
EmailConfirmed = true,
FullName = "SysAdmin",
LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEJwGvD0ionYUADG6FQvuXiK0/897GSnJ8z55w1P0GaItbNjjypF1+aDuRViCZMUQ+g==",
PhoneNumberConfirmed = false,
SecurityStamp = "50df1ec2-4ba7-4eb5-84a3-ffb35b44f391",
TwoFactorEnabled = false,
UserName = "sysadmin@pstw.com.my"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany("Departments")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Areas.Inventory.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("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.Areas.Inventory.Models.CompanyModel", b =>
{
b.Navigation("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Navigation("Items");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,511 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PSTW_CentralSystem.Migrations
{
/// <inheritdoc />
public partial class Initiate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
FullName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UserStatus = table.Column<int>(type: "int", nullable: true),
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedEmail = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
PasswordHash = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SecurityStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
CompanyId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Companies", x => x.CompanyId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Manufacturers",
columns: table => new
{
ManufacturerId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ManufacturerName = table.Column<string>(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
{
SettingId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ModuleName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
AllowedUserType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MethodAllowedUserType = table.Column<string>(type: "json", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ModuleStatus = table.Column<int>(type: "int", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ModuleSettings", x => x.SettingId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Suppliers",
columns: table => new
{
SupplierId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
SupplierName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierGender = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierEmail = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierPhoneNo = table.Column<string>(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
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<int>(type: "int", nullable: false),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<int>(type: "int", nullable: false),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderKey = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderDisplayName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<int>(type: "int", nullable: false),
RoleId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<int>(type: "int", nullable: false),
LoginProvider = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Value = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Departments",
columns: table => new
{
DepartmentId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DepartmentName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CompanyId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Departments", x => x.DepartmentId);
table.ForeignKey(
name: "FK_Departments_Companies_CompanyId",
column: x => x.CompanyId,
principalTable: "Companies",
principalColumn: "CompanyId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
ProductId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ProductName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ManufacturerId = table.Column<int>(type: "int", nullable: false),
Category = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ModelNo = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
QuantityProduct = table.Column<int>(type: "int", nullable: true),
ImageProduct = table.Column<string>(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: "Items",
columns: table => new
{
ItemID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UniqueID = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CompanyId = table.Column<int>(type: "int", nullable: false),
DepartmentId = table.Column<int>(type: "int", nullable: false),
ProductId = table.Column<int>(type: "int", nullable: false),
SerialNumber = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Quantity = table.Column<int>(type: "int", nullable: false),
Supplier = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PurchaseDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
PONo = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Currency = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PriceInRM = table.Column<float>(type: "float", nullable: false),
CurrencyRate = table.Column<float>(type: "float", nullable: false),
ConvertPrice = table.Column<float>(type: "float", nullable: false),
DODate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Warranty = table.Column<int>(type: "int", nullable: false),
EndWDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
InvoiceDate = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.ItemID);
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" },
values: new object[,]
{
{ 1, null, "Can access all pages", "SuperAdmin", "SUPERADMIN" },
{ 2, null, "Can access some admin pages", "SystemAdmin", "SYSTEMADMIN" },
{ 3, null, "Can access operation pages", "Engineer", "ENGINEER" },
{ 4, null, "Can access data viewer pages", "Observer", "OBSERVER" }
});
migrationBuilder.InsertData(
table: "AspNetUsers",
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FullName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName", "UserStatus" },
values: new object[,]
{
{ 1, 0, "df01136b-c869-4bc3-9512-34a9cdc8f73d", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAECcU3fIsIpqE1gECPg262gMejQiypGUXipVbiRtF66ywBqUHdohCj89hiJAafOlrPQ==", null, false, "d36451ff-cfab-46e1-bf80-6b428d79a19b", false, "admin@pstw.com.my", null },
{ 2, 0, "6f7244cf-e611-4088-890a-72939cfbefa5", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEJwGvD0ionYUADG6FQvuXiK0/897GSnJ8z55w1P0GaItbNjjypF1+aDuRViCZMUQ+g==", null, false, "50df1ec2-4ba7-4eb5-84a3-ffb35b44f391", false, "sysadmin@pstw.com.my", null }
});
migrationBuilder.InsertData(
table: "AspNetUserRoles",
columns: new[] { "RoleId", "UserId" },
values: new object[] { 1, 1 });
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Departments_CompanyId",
table: "Departments",
column: "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_Items_CompanyId",
table: "Items",
column: "CompanyId");
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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
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: "Departments");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Companies");
migrationBuilder.DropTable(
name: "Manufacturers");
}
}
}

View File

@ -1,647 +0,0 @@
// <auto-generated />
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
{
[DbContext(typeof(AuthDBContext))]
[Migration("20241129023507_UpdateItemModel")]
partial class UpdateItemModel
{
/// <inheritdoc />
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("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
b.HasData(
new
{
UserId = 1,
RoleId = 1
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", b =>
{
b.Property<int>("CompanyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("CompanyId"));
b.Property<string>("CompanyName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("CompanyId");
b.ToTable("Companies");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.Property<int>("DepartmentId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("DepartmentId"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<string>("DepartmentName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("DepartmentId");
b.HasIndex("CompanyId");
b.ToTable("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.Property<int>("ItemID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ItemID"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<float>("ConvertPrice")
.HasColumnType("float");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("CurrencyRate")
.HasColumnType("float");
b.Property<DateTime>("DODate")
.HasColumnType("datetime(6)");
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<DateTime>("EndWDate")
.HasColumnType("datetime(6)");
b.Property<DateTime>("InvoiceDate")
.HasColumnType("datetime(6)");
b.Property<string>("PONo")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("PriceInRM")
.HasColumnType("float");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<DateTime>("PurchaseDate")
.HasColumnType("datetime(6)");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<string>("SerialNumber")
.HasColumnType("longtext");
b.Property<string>("Supplier")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("UniqueID")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Warranty")
.HasColumnType("int");
b.HasKey("ItemID");
b.HasIndex("CompanyId");
b.HasIndex("DepartmentId");
b.HasIndex("ProductId");
b.ToTable("Items");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
{
b.Property<int>("ManufacturerId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ManufacturerId"));
b.Property<string>("ManufacturerName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("ManufacturerId");
b.ToTable("Manufacturers");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Property<int>("ProductId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ProductId"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ImageProduct")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("ManufacturerId")
.HasColumnType("int");
b.Property<string>("ModelNo")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("QuantityProduct")
.HasColumnType("int");
b.HasKey("ProductId");
b.HasIndex("ManufacturerId");
b.ToTable("Products");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SupplierId"));
b.Property<string>("SupplierEmail")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierGender")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierPhoneNo")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("SupplierId");
b.ToTable("Suppliers");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b =>
{
b.Property<int>("SettingId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SettingId"));
b.Property<string>("AllowedUserType")
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("MethodAllowedUserType")
.HasColumnType("json");
b.Property<string>("ModuleName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("ModuleStatus")
.HasColumnType("int");
b.HasKey("SettingId");
b.ToTable("ModuleSettings");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = 1,
Description = "Can access all pages",
Name = "SuperAdmin",
NormalizedName = "SUPERADMIN"
},
new
{
Id = 2,
Description = "Can access some admin pages",
Name = "SystemAdmin",
NormalizedName = "SYSTEMADMIN"
},
new
{
Id = 3,
Description = "Can access operation pages",
Name = "Engineer",
NormalizedName = "ENGINEER"
},
new
{
Id = 4,
Description = "Can access data viewer pages",
Name = "Observer",
NormalizedName = "OBSERVER"
});
});
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("FullName")
.HasColumnType("longtext");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int?>("UserStatus")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
b.HasData(
new
{
Id = 1,
AccessFailedCount = 0,
ConcurrencyStamp = "9577ec05-b14b-4fe2-9d75-cb6aa1ce25be",
Email = "admin@pstw.com.my",
EmailConfirmed = true,
FullName = "MAAdmin",
LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEKPk6s6BTBEv5y5S9pOYk6OvLO6XfHhiylslKoOPbAQIAaG9DJZ27ltRHKwe34Na6w==",
PhoneNumberConfirmed = false,
SecurityStamp = "8f828c08-90d7-4a77-a8b0-a317e7ecadbc",
TwoFactorEnabled = false,
UserName = "admin@pstw.com.my"
},
new
{
Id = 2,
AccessFailedCount = 0,
ConcurrencyStamp = "75cb87bb-bba0-410e-83a0-b23b54dfa2f6",
Email = "sysadmin@pstw.com.my",
EmailConfirmed = true,
FullName = "SysAdmin",
LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEPmeMMNew971MNbCbXypkCQ9L2EFXyjcFUhEjX7aPJCC4B+aRavO/201MVOvU/VFIQ==",
PhoneNumberConfirmed = false,
SecurityStamp = "4480b7af-adbc-4d83-9527-511f99593aac",
TwoFactorEnabled = false,
UserName = "sysadmin@pstw.com.my"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany("Departments")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Areas.Inventory.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("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.Areas.Inventory.Models.CompanyModel", b =>
{
b.Navigation("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Navigation("Items");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,74 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PSTW_CentralSystem.Migrations
{
/// <inheritdoc />
public partial class UpdateItemModel : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "SerialNumber",
table: "Items",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "9577ec05-b14b-4fe2-9d75-cb6aa1ce25be", "AQAAAAIAAYagAAAAEKPk6s6BTBEv5y5S9pOYk6OvLO6XfHhiylslKoOPbAQIAaG9DJZ27ltRHKwe34Na6w==", "8f828c08-90d7-4a77-a8b0-a317e7ecadbc" });
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "75cb87bb-bba0-410e-83a0-b23b54dfa2f6", "AQAAAAIAAYagAAAAEPmeMMNew971MNbCbXypkCQ9L2EFXyjcFUhEjX7aPJCC4B+aRavO/201MVOvU/VFIQ==", "4480b7af-adbc-4d83-9527-511f99593aac" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Items",
keyColumn: "SerialNumber",
keyValue: null,
column: "SerialNumber",
value: "");
migrationBuilder.AlterColumn<string>(
name: "SerialNumber",
table: "Items",
type: "longtext",
nullable: false,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "df01136b-c869-4bc3-9512-34a9cdc8f73d", "AQAAAAIAAYagAAAAECcU3fIsIpqE1gECPg262gMejQiypGUXipVbiRtF66ywBqUHdohCj89hiJAafOlrPQ==", "d36451ff-cfab-46e1-bf80-6b428d79a19b" });
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "6f7244cf-e611-4088-890a-72939cfbefa5", "AQAAAAIAAYagAAAAEJwGvD0ionYUADG6FQvuXiK0/897GSnJ8z55w1P0GaItbNjjypF1+aDuRViCZMUQ+g==", "50df1ec2-4ba7-4eb5-84a3-ffb35b44f391" });
}
}
}

View File

@ -1,644 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSTW_CentralSystem.DBContext;
#nullable disable
namespace PSTW_CentralSystem.Migrations
{
[DbContext(typeof(AuthDBContext))]
partial class AuthDBContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
b.HasData(
new
{
UserId = 1,
RoleId = 1
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", b =>
{
b.Property<int>("CompanyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("CompanyId"));
b.Property<string>("CompanyName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("CompanyId");
b.ToTable("Companies");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.Property<int>("DepartmentId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("DepartmentId"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<string>("DepartmentName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("DepartmentId");
b.HasIndex("CompanyId");
b.ToTable("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.Property<int>("ItemID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ItemID"));
b.Property<int>("CompanyId")
.HasColumnType("int");
b.Property<float>("ConvertPrice")
.HasColumnType("float");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("CurrencyRate")
.HasColumnType("float");
b.Property<DateTime>("DODate")
.HasColumnType("datetime(6)");
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<DateTime>("EndWDate")
.HasColumnType("datetime(6)");
b.Property<DateTime>("InvoiceDate")
.HasColumnType("datetime(6)");
b.Property<string>("PONo")
.IsRequired()
.HasColumnType("longtext");
b.Property<float>("PriceInRM")
.HasColumnType("float");
b.Property<int>("ProductId")
.HasColumnType("int");
b.Property<DateTime>("PurchaseDate")
.HasColumnType("datetime(6)");
b.Property<int>("Quantity")
.HasColumnType("int");
b.Property<string>("SerialNumber")
.HasColumnType("longtext");
b.Property<string>("Supplier")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("UniqueID")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Warranty")
.HasColumnType("int");
b.HasKey("ItemID");
b.HasIndex("CompanyId");
b.HasIndex("DepartmentId");
b.HasIndex("ProductId");
b.ToTable("Items");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
{
b.Property<int>("ManufacturerId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ManufacturerId"));
b.Property<string>("ManufacturerName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("ManufacturerId");
b.ToTable("Manufacturers");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Property<int>("ProductId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("ProductId"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ImageProduct")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("ManufacturerId")
.HasColumnType("int");
b.Property<string>("ModelNo")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("QuantityProduct")
.HasColumnType("int");
b.HasKey("ProductId");
b.HasIndex("ManufacturerId");
b.ToTable("Products");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SupplierId"));
b.Property<string>("SupplierEmail")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierGender")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("SupplierPhoneNo")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("SupplierId");
b.ToTable("Suppliers");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b =>
{
b.Property<int>("SettingId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("SettingId"));
b.Property<string>("AllowedUserType")
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("MethodAllowedUserType")
.HasColumnType("json");
b.Property<string>("ModuleName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("ModuleStatus")
.HasColumnType("int");
b.HasKey("SettingId");
b.ToTable("ModuleSettings");
});
modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
b.HasData(
new
{
Id = 1,
Description = "Can access all pages",
Name = "SuperAdmin",
NormalizedName = "SUPERADMIN"
},
new
{
Id = 2,
Description = "Can access some admin pages",
Name = "SystemAdmin",
NormalizedName = "SYSTEMADMIN"
},
new
{
Id = 3,
Description = "Can access operation pages",
Name = "Engineer",
NormalizedName = "ENGINEER"
},
new
{
Id = 4,
Description = "Can access data viewer pages",
Name = "Observer",
NormalizedName = "OBSERVER"
});
});
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("FullName")
.HasColumnType("longtext");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<int?>("UserStatus")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
b.HasData(
new
{
Id = 1,
AccessFailedCount = 0,
ConcurrencyStamp = "9577ec05-b14b-4fe2-9d75-cb6aa1ce25be",
Email = "admin@pstw.com.my",
EmailConfirmed = true,
FullName = "MAAdmin",
LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEKPk6s6BTBEv5y5S9pOYk6OvLO6XfHhiylslKoOPbAQIAaG9DJZ27ltRHKwe34Na6w==",
PhoneNumberConfirmed = false,
SecurityStamp = "8f828c08-90d7-4a77-a8b0-a317e7ecadbc",
TwoFactorEnabled = false,
UserName = "admin@pstw.com.my"
},
new
{
Id = 2,
AccessFailedCount = 0,
ConcurrencyStamp = "75cb87bb-bba0-410e-83a0-b23b54dfa2f6",
Email = "sysadmin@pstw.com.my",
EmailConfirmed = true,
FullName = "SysAdmin",
LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEPmeMMNew971MNbCbXypkCQ9L2EFXyjcFUhEjX7aPJCC4B+aRavO/201MVOvU/VFIQ==",
PhoneNumberConfirmed = false,
SecurityStamp = "4480b7af-adbc-4d83-9527-511f99593aac",
TwoFactorEnabled = false,
UserName = "sysadmin@pstw.com.my"
});
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.RoleModel", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("PSTW_CentralSystem.Models.UserModel", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.DepartmentModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany("Departments")
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Company");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
{
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.CompanyModel", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSTW_CentralSystem.Areas.Inventory.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("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.Areas.Inventory.Models.CompanyModel", b =>
{
b.Navigation("Departments");
});
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
{
b.Navigation("Items");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PSTW_CentralSystem.Areas.Inventory.Models namespace PSTW_CentralSystem.Models
{ {
public class CompanyModel public class CompanyModel
{ {

View File

@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PSTW_CentralSystem.Areas.Inventory.Models namespace PSTW_CentralSystem.Models
{ {
public class DepartmentModel public class DepartmentModel
{ {
[Key] [Key]
public int DepartmentId { get; set; } public int DepartmentId { get; set; }
public required string DepartmentName { get; set; } public required string DepartmentName { get; set; }
public required string DepartmentCode { get; set; }
public required int CompanyId { get; set; } public required int CompanyId { get; set; }
[ForeignKey("CompanyId")] [ForeignKey("CompanyId")]

View File

@ -30,6 +30,7 @@
<Folder Include="Controllers\JSA\API\" /> <Folder Include="Controllers\JSA\API\" />
<Folder Include="Logs\" /> <Folder Include="Logs\" />
<Folder Include="Migrations\" /> <Folder Include="Migrations\" />
<Folder Include="Views\JSA\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -11,7 +11,8 @@ internal class Program
private static void Main(string[] args) private static void Main(string[] args)
{ {
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); var authConnectionString = builder.Configuration.GetConnectionString("AuthConnnection");
var inventoryConnectionString = builder.Configuration.GetConnectionString("InventoryConnection");
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
@ -34,9 +35,15 @@ internal class Program
builder.Logging.AddSerilog(); builder.Logging.AddSerilog();
builder.Services.AddDbContext<AuthDBContext>(options => builder.Services.AddDbContext<IdentityDBContext>(options =>
{ {
options.UseMySql(connectionString, new MySqlServerVersion(new Version(8, 0, 39)), options.UseMySql(authConnectionString, new MySqlServerVersion(new Version(8, 0, 39)),
mysqlOptions => mysqlOptions.CommandTimeout(120)
);
});
builder.Services.AddDbContext<InventoryDBContext>(options =>
{
options.UseMySql(inventoryConnectionString, new MySqlServerVersion(new Version(8, 0, 39)),
mysqlOptions => mysqlOptions.CommandTimeout(120) mysqlOptions => mysqlOptions.CommandTimeout(120)
); );
}); });
@ -44,7 +51,7 @@ internal class Program
//builder.Services.AddDefaultIdentity<UserModel>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<AuthDBContext>(); //builder.Services.AddDefaultIdentity<UserModel>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<AuthDBContext>();
builder.Services.AddIdentity<UserModel, RoleModel>(options => options.SignIn.RequireConfirmedAccount = true) builder.Services.AddIdentity<UserModel, RoleModel>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<AuthDBContext>() .AddEntityFrameworkStores<IdentityDBContext>()
.AddDefaultUI() .AddDefaultUI()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();

View File

@ -2,6 +2,9 @@
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@ *@
@{ @{
@using Microsoft.AspNetCore.Identity;
@inject UserManager<UserModel> _userManager;
var user = await _userManager.GetUserAsync(User);
} }
@ -727,5 +730,38 @@
<!-- Datatables JS--> <!-- Datatables JS-->
<script src="~/lib/datatables/datatables.js"></script> <script src="~/lib/datatables/datatables.js"></script>
@await RenderSectionAsync("Scripts", required: false) @await RenderSectionAsync("Scripts", required: false)
<script>
$(function () {
app.mount("#main-wrapper");
});
const app = Vue.createApp({
data() {
return {
user: null,
}
},
mounted() {
this.fetchUser();
},
methods: {
async fetchUser() {
fetch(`/IdentityAPI/GetUserInformation/@user?.Id`, {
method: 'POST'
})
.then(response => response.json())
.then(data => {
if (data != null) {
this.user = data;
}
console.log(data)
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
},
},
});
</script>
</body> </body>
</html> </html>

View File

@ -2,7 +2,8 @@
"ConnectionStrings": { "ConnectionStrings": {
//"DefaultConnection": "Server=localhost;uid=root;Password='';Database=web_interface;" //"DefaultConnection": "Server=localhost;uid=root;Password='';Database=web_interface;"
//"DefaultConnection": "server=175.136.244.102;user id=root;password=tw_mysql_root;port=3306;database=web_interface" //"DefaultConnection": "server=175.136.244.102;user id=root;password=tw_mysql_root;port=3306;database=web_interface"
"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs;" //DB_dev connection "AuthConnnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs_auth;", //DB_dev connection
"InventoryConnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs_inventory;" //DB_dev connection
//"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=intern;password='intern_mysql_acct';database=web_interface;"//DB_dev connection //"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=intern;password='intern_mysql_acct';database=web_interface;"//DB_dev connection
}, },
"Logging": { "Logging": {