Update
This commit is contained in:
parent
8135725180
commit
907a171616
@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using PSTW_CentralSystem.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
||||
{
|
||||
@ -12,69 +9,44 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
||||
//[Authorize(Policy = "RoleModulePolicy")]
|
||||
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
|
||||
public ActionResult Index()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ItemRegistration()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ProductRegistration()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
||||
{
|
||||
@ -9,68 +8,43 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers
|
||||
//[Authorize(Policy = "RoleModulePolicy")]
|
||||
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
|
||||
public ActionResult Index()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult SupplierRegistration()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
public IActionResult ManifacturerRegistration()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: Inventory/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
return View(userId);
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
|
||||
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")]
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
@{
|
||||
ViewData["Title"] = "Item Form";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
string userId = ViewBag.UserId;
|
||||
}
|
||||
|
||||
<style>
|
||||
.table td img {
|
||||
display: block !important;
|
||||
@ -388,6 +386,8 @@
|
||||
loading: false,
|
||||
thisQR: null,
|
||||
items: [],
|
||||
currentUser: null,
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {// Log the token to check its value
|
||||
@ -398,6 +398,7 @@
|
||||
this.fetchCompanies();
|
||||
this.fetchProducts();
|
||||
this.fetchSuppliers();
|
||||
this.fetchUser();
|
||||
},
|
||||
computed: {
|
||||
filteredDepartments() {
|
||||
@ -439,7 +440,8 @@
|
||||
DODate: this.DODate,
|
||||
Warranty: this.warranty,
|
||||
EndWDate: this.EndWDate,
|
||||
InvoiceDate: this.invoiceDate
|
||||
InvoiceDate: this.invoiceDate,
|
||||
CreatedByUserId: this.currentUser,
|
||||
};
|
||||
|
||||
try {
|
||||
@ -824,6 +826,23 @@
|
||||
alert("An error occurred while generating the QR code.");
|
||||
}
|
||||
},
|
||||
async fetchUser() {
|
||||
try {
|
||||
const response = await fetch(`/IdentityAPI/GetUserInformation/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
this.currentUser = data?.UserInfo || null;
|
||||
}
|
||||
else {
|
||||
console.error(`Failed to fetch user: ${response.statusText}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PSTW_CentralSystem.DBContext;
|
||||
using PSTW_CentralSystem.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PSTW_CentralSystem.Controllers.API
|
||||
@ -11,11 +14,13 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IdentityDBContext _authDbContext;
|
||||
private readonly UserManager<UserModel> _userManager;
|
||||
|
||||
public AdminAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
|
||||
public AdminAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext, UserManager<UserModel> userManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_authDbContext = authDbContext;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[HttpPost("GetClassAndMethodInformation")]
|
||||
@ -45,6 +50,7 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
// Return the list as JSON
|
||||
return Json(controllerAndMethodList);
|
||||
}
|
||||
|
||||
[HttpPost("GetListClassAndMethodInformation")]
|
||||
public async Task<IActionResult> GetListClassAndMethodInformation()
|
||||
{
|
||||
@ -73,6 +79,44 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
// Return the list as JSON
|
||||
return Json(controllerAndMethodList);
|
||||
}
|
||||
[HttpPost("GetUserList")]
|
||||
public async Task<IActionResult> GetUserList()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
|
||||
var userRole = await _userManager.GetRolesAsync(user??new UserModel());
|
||||
List<UserModel> userInfo = new List<UserModel>();
|
||||
|
||||
if (userRole == null || userRole.Count == 0)
|
||||
{
|
||||
// Fetch all users excluding those with roles SuperAdmin or SystemAdmin
|
||||
var allUsers = await _authDbContext.Users
|
||||
.Include(u => u.Department)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var u in allUsers)
|
||||
{
|
||||
var roles = await _userManager.GetRolesAsync(u);
|
||||
if (!roles.Contains("SuperAdmin") && !roles.Contains("SystemAdmin"))
|
||||
{
|
||||
userInfo.Add(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo = await _authDbContext.Users.Include(u => u.Department).ToListAsync();
|
||||
}
|
||||
|
||||
return Ok(new { UserInfo = userInfo });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,57 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PSTW_CentralSystem.DBContext;
|
||||
using PSTW_CentralSystem.Models;
|
||||
namespace PSTW_CentralSystem.Controllers.API
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
|
||||
public class IdentityAPI : Controller
|
||||
public class IdentityAPI : ControllerBase
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly ILogger<IdentityAPI> _logger;
|
||||
private readonly IdentityDBContext _authDbContext;
|
||||
private readonly UserManager<UserModel> _userManager;
|
||||
|
||||
public IdentityAPI(ILogger<HomeController> logger, IdentityDBContext authDbContext)
|
||||
public IdentityAPI(ILogger<IdentityAPI> logger, IdentityDBContext authDbContext, UserManager<UserModel> userManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_authDbContext = authDbContext;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[HttpPost("GetUserInformation/{id}")]
|
||||
public async Task<IActionResult> GetModuleInformation(int id)
|
||||
[HttpPost("GetUserInformation/")]
|
||||
public async Task<IActionResult> GetUserInformation()
|
||||
{
|
||||
var userInfo = await _authDbContext.Users.Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
return Json("userInfo");
|
||||
try
|
||||
{
|
||||
var user = await _userManager.GetUserAsync(User);
|
||||
var userRole = await _userManager.GetRolesAsync(user!);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
|
||||
}
|
||||
|
||||
var userInfo = await _authDbContext.Users.Include(u => u.Department).Select(u => new
|
||||
{
|
||||
u.Id,
|
||||
u.NormalizedEmail,
|
||||
u.Department,
|
||||
userRole,
|
||||
}).Where(u => u.Id == user.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (userInfo == null)
|
||||
{
|
||||
return NotFound("User not found");
|
||||
}
|
||||
|
||||
return Ok(new { UserInfo = userInfo });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ namespace PSTW_CentralSystem.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ModuleSetting(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
@ -48,5 +49,19 @@ namespace PSTW_CentralSystem.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult UserAdmin()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult UserSetting()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult UserCreate()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
470
Migrations/20241206015840_Initiate.Designer.cs
generated
Normal file
470
Migrations/20241206015840_Initiate.Designer.cs
generated
Normal file
@ -0,0 +1,470 @@
|
||||
// <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(IdentityDBContext))]
|
||||
[Migration("20241206015840_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
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 2,
|
||||
RoleId = 2
|
||||
});
|
||||
});
|
||||
|
||||
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.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.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>("DepartmentCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("DepartmentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("DepartmentId");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("Departments");
|
||||
});
|
||||
|
||||
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.Property<int?>("departmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.HasIndex("departmentId");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "b58597b6-2835-4ff6-b437-11ec7a213434",
|
||||
Email = "admin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "MAAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "ADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "ADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAECA03al9kGFTKlmmTls3wiH4NV7HlL76680Qx6lR7d77LHJwIN6/Wt1MBCP9TE1qfg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "0f649a27-6566-436c-bc27-d1a6b8e7f846",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "admin@pstw.com.my"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "cf9424fc-8afc-4f59-a0a6-34574676273c",
|
||||
Email = "sysadmin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "SysAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEMkwXv250FjOjdLEAY2a/aEF3g3iu9xCVORV/MH37kVcj8vgJez+LlfJtjklaschLg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "8efe9683-78fb-404d-96a9-b8b7302c03b2",
|
||||
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.Models.DepartmentModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany("Departments")
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("departmentId");
|
||||
|
||||
b.Navigation("Department");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
|
||||
{
|
||||
b.Navigation("Departments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
378
Migrations/20241206015840_Initiate.cs
Normal file
378
Migrations/20241206015840_Initiate.cs
Normal file
@ -0,0 +1,378 @@
|
||||
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: "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: "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: "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: "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"),
|
||||
DepartmentCode = 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: "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),
|
||||
departmentId = 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);
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUsers_Departments_departmentId",
|
||||
column: x => x.departmentId,
|
||||
principalTable: "Departments",
|
||||
principalColumn: "DepartmentId");
|
||||
})
|
||||
.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.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", "departmentId" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 1, 0, "b58597b6-2835-4ff6-b437-11ec7a213434", "admin@pstw.com.my", true, "MAAdmin", false, null, "ADMIN@PSTW.COM.MY", "ADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAECA03al9kGFTKlmmTls3wiH4NV7HlL76680Qx6lR7d77LHJwIN6/Wt1MBCP9TE1qfg==", null, false, "0f649a27-6566-436c-bc27-d1a6b8e7f846", false, "admin@pstw.com.my", null, null },
|
||||
{ 2, 0, "cf9424fc-8afc-4f59-a0a6-34574676273c", "sysadmin@pstw.com.my", true, "SysAdmin", false, null, "SYSADMIN@PSTW.COM.MY", "SYSADMIN@PSTW.COM.MY", "AQAAAAIAAYagAAAAEMkwXv250FjOjdLEAY2a/aEF3g3iu9xCVORV/MH37kVcj8vgJez+LlfJtjklaschLg==", null, false, "8efe9683-78fb-404d-96a9-b8b7302c03b2", false, "sysadmin@pstw.com.my", null, null }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "AspNetUserRoles",
|
||||
columns: new[] { "RoleId", "UserId" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 1, 1 },
|
||||
{ 2, 2 }
|
||||
});
|
||||
|
||||
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: "IX_AspNetUsers_departmentId",
|
||||
table: "AspNetUsers",
|
||||
column: "departmentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedUserName",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Departments_CompanyId",
|
||||
table: "Departments",
|
||||
column: "CompanyId");
|
||||
}
|
||||
|
||||
/// <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: "ModuleSettings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetRoles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Departments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Companies");
|
||||
}
|
||||
}
|
||||
}
|
||||
467
Migrations/IdentityDBContextModelSnapshot.cs
Normal file
467
Migrations/IdentityDBContextModelSnapshot.cs
Normal file
@ -0,0 +1,467 @@
|
||||
// <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(IdentityDBContext))]
|
||||
partial class IdentityDBContextModelSnapshot : 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
|
||||
},
|
||||
new
|
||||
{
|
||||
UserId = 2,
|
||||
RoleId = 2
|
||||
});
|
||||
});
|
||||
|
||||
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.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.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>("DepartmentCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("DepartmentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("DepartmentId");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("Departments");
|
||||
});
|
||||
|
||||
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.Property<int?>("departmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.HasIndex("departmentId");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "b58597b6-2835-4ff6-b437-11ec7a213434",
|
||||
Email = "admin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "MAAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "ADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "ADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAECA03al9kGFTKlmmTls3wiH4NV7HlL76680Qx6lR7d77LHJwIN6/Wt1MBCP9TE1qfg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "0f649a27-6566-436c-bc27-d1a6b8e7f846",
|
||||
TwoFactorEnabled = false,
|
||||
UserName = "admin@pstw.com.my"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "cf9424fc-8afc-4f59-a0a6-34574676273c",
|
||||
Email = "sysadmin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "SysAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEMkwXv250FjOjdLEAY2a/aEF3g3iu9xCVORV/MH37kVcj8vgJez+LlfJtjklaschLg==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "8efe9683-78fb-404d-96a9-b8b7302c03b2",
|
||||
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.Models.DepartmentModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany("Departments")
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("departmentId");
|
||||
|
||||
b.Navigation("Department");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
|
||||
{
|
||||
b.Navigation("Departments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
394
Migrations/InventoryDB/20241206071642_Initiate.Designer.cs
generated
Normal file
394
Migrations/InventoryDB/20241206071642_Initiate.Designer.cs
generated
Normal file
@ -0,0 +1,394 @@
|
||||
// <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.InventoryDB
|
||||
{
|
||||
[DbContext(typeof(InventoryDBContext))]
|
||||
[Migration("20241206071642_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("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<int>("CreatedByUserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<float>("CurrencyRate")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DODate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("DONo")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("DepartmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("EndWDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("InvoiceDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("InvoiceNo")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ItemLocation")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ItemStatus")
|
||||
.HasColumnType("int")
|
||||
.HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
|
||||
|
||||
b.Property<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>("TeamType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("UniqueID")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("Warranty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ItemID");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.HasIndex("CreatedByUserId");
|
||||
|
||||
b.HasIndex("DepartmentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
|
||||
{
|
||||
b.Property<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.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("CompanyModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.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>("DepartmentCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("DepartmentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("DepartmentId");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("DepartmentModel");
|
||||
});
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("UserStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("departmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("departmentId");
|
||||
|
||||
b.ToTable("UserModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany()
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Models.UserModel", "CreatedBy")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedByUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("DepartmentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
|
||||
b.Navigation("CreatedBy");
|
||||
|
||||
b.Navigation("Department");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ManufacturerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacturer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany("Departments")
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("departmentId");
|
||||
|
||||
b.Navigation("Department");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
|
||||
{
|
||||
b.Navigation("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
|
||||
{
|
||||
b.Navigation("Departments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
296
Migrations/InventoryDB/20241206071642_Initiate.cs
Normal file
296
Migrations/InventoryDB/20241206071642_Initiate.cs
Normal file
@ -0,0 +1,296 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PSTW_CentralSystem.Migrations.InventoryDB
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initiate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterDatabase()
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CompanyModel",
|
||||
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_CompanyModel", 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: "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: "DepartmentModel",
|
||||
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"),
|
||||
DepartmentCode = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CompanyId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DepartmentModel", x => x.DepartmentId);
|
||||
table.ForeignKey(
|
||||
name: "FK_DepartmentModel_CompanyModel_CompanyId",
|
||||
column: x => x.CompanyId,
|
||||
principalTable: "CompanyModel",
|
||||
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: "UserModel",
|
||||
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),
|
||||
departmentId = table.Column<int>(type: "int", nullable: true),
|
||||
UserName = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
NormalizedUserName = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Email = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
NormalizedEmail = table.Column<string>(type: "longtext", 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_UserModel", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserModel_DepartmentModel_departmentId",
|
||||
column: x => x.departmentId,
|
||||
principalTable: "DepartmentModel",
|
||||
principalColumn: "DepartmentId");
|
||||
})
|
||||
.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: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TeamType = table.Column<string>(type: "longtext", nullable: true)
|
||||
.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),
|
||||
DONo = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
DODate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
Warranty = table.Column<int>(type: "int", nullable: false),
|
||||
EndWDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
InvoiceNo = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
InvoiceDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
ItemStatus = table.Column<int>(type: "int", nullable: false, comment: "1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"),
|
||||
ItemLocation = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedByUserId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Items", x => x.ItemID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Items_CompanyModel_CompanyId",
|
||||
column: x => x.CompanyId,
|
||||
principalTable: "CompanyModel",
|
||||
principalColumn: "CompanyId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Items_DepartmentModel_DepartmentId",
|
||||
column: x => x.DepartmentId,
|
||||
principalTable: "DepartmentModel",
|
||||
principalColumn: "DepartmentId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Items_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ProductId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Items_UserModel_CreatedByUserId",
|
||||
column: x => x.CreatedByUserId,
|
||||
principalTable: "UserModel",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DepartmentModel_CompanyId",
|
||||
table: "DepartmentModel",
|
||||
column: "CompanyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Items_CompanyId",
|
||||
table: "Items",
|
||||
column: "CompanyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Items_CreatedByUserId",
|
||||
table: "Items",
|
||||
column: "CreatedByUserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Items_DepartmentId",
|
||||
table: "Items",
|
||||
column: "DepartmentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Items_ProductId",
|
||||
table: "Items",
|
||||
column: "ProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_ManufacturerId",
|
||||
table: "Products",
|
||||
column: "ManufacturerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserModel_departmentId",
|
||||
table: "UserModel",
|
||||
column: "departmentId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Items");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Suppliers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserModel");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Manufacturers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DepartmentModel");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CompanyModel");
|
||||
}
|
||||
}
|
||||
}
|
||||
391
Migrations/InventoryDB/InventoryDBContextModelSnapshot.cs
Normal file
391
Migrations/InventoryDB/InventoryDBContextModelSnapshot.cs
Normal file
@ -0,0 +1,391 @@
|
||||
// <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.InventoryDB
|
||||
{
|
||||
[DbContext(typeof(InventoryDBContext))]
|
||||
partial class InventoryDBContextModelSnapshot : 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("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<int>("CreatedByUserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Currency")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<float>("CurrencyRate")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DODate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("DONo")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("DepartmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("EndWDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<DateTime?>("InvoiceDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("InvoiceNo")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ItemLocation")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("ItemStatus")
|
||||
.HasColumnType("int")
|
||||
.HasComment("1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;");
|
||||
|
||||
b.Property<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>("TeamType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("UniqueID")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("Warranty")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ItemID");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.HasIndex("CreatedByUserId");
|
||||
|
||||
b.HasIndex("DepartmentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
|
||||
{
|
||||
b.Property<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.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("CompanyModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.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>("DepartmentCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("DepartmentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("DepartmentId");
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("DepartmentModel");
|
||||
});
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
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")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("UserStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("departmentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("departmentId");
|
||||
|
||||
b.ToTable("UserModel");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany()
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Models.UserModel", "CreatedBy")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedByUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("DepartmentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", "Product")
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
|
||||
b.Navigation("CreatedBy");
|
||||
|
||||
b.Navigation("Department");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", "Manufacturer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ManufacturerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacturer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.CompanyModel", "Company")
|
||||
.WithMany("Departments")
|
||||
.HasForeignKey("CompanyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.UserModel", b =>
|
||||
{
|
||||
b.HasOne("PSTW_CentralSystem.Models.DepartmentModel", "Department")
|
||||
.WithMany()
|
||||
.HasForeignKey("departmentId");
|
||||
|
||||
b.Navigation("Department");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
|
||||
{
|
||||
b.Navigation("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
|
||||
{
|
||||
b.Navigation("Departments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,5 +9,9 @@ namespace PSTW_CentralSystem.Models
|
||||
// Add custom properties
|
||||
public string? FullName { get; set; }
|
||||
public int? UserStatus { get; set; }
|
||||
public int? departmentId { get; set; }
|
||||
[ForeignKey("departmentId")]
|
||||
public virtual DepartmentModel? Department { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,11 @@ internal class Program
|
||||
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"))
|
||||
.WriteTo.Console()
|
||||
.CreateLogger();
|
||||
// Set default session to 30 minutes
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromDays(30);
|
||||
});
|
||||
|
||||
builder.Logging.AddSerilog();
|
||||
|
||||
|
||||
@ -7,13 +7,27 @@
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="card card-hover">
|
||||
<div class="box bg-cyan text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-view-dashboard"></i>
|
||||
</h1>
|
||||
<h6 class="text-white">Dashboard</h6>
|
||||
<a asp-controller="Admin" asp-action="UserAdmin">
|
||||
<div class="card card-hover">
|
||||
<div class="box bg-cyan text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-view-dashboard"></i>
|
||||
</h1>
|
||||
<h6 class="text-white">Dashboard</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<a asp-controller="Admin" asp-action="UserAdmin">
|
||||
<div class="card card-hover">
|
||||
<div class="box bg-cyan text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-human"></i>
|
||||
</h1>
|
||||
<h6 class="text-white">User Administration</h6>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
241
Views/Admin/UserAdmin.cshtml
Normal file
241
Views/Admin/UserAdmin.cshtml
Normal file
@ -0,0 +1,241 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
ViewData["Title"] = "User Administration";
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="UserCreate">Create New</a>
|
||||
</p>
|
||||
<div id="app">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Latest Posts</h4>
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div>
|
||||
<table class="table table-bordered border-primary" id="userDatatable">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- MODAL -->
|
||||
<div class="modal fade" id="confirm-dialog" tabindex="-1" role="dialog" aria-labelledby="confirm-dialog-title" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="confirm-dialog-title">Confirmation</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" v-on:click="hideModal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="selectedModule">
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete module {{ selectedModule.moduleName }}?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="hideModal">Cancel</button>
|
||||
<input type="hidden" id="delete-id">
|
||||
<a id="confirmButton" href="#" class="btn btn-danger" v-on:click="confirmDelete(selectedModule)">Confirm</a>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else><p>Loading...</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
<script>
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
userList: null,
|
||||
selectedModule: null
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.fetchModule();
|
||||
},
|
||||
methods: {
|
||||
fetchModule() {
|
||||
fetch('/AdminAPI/GetUserList', {
|
||||
method: 'POST'
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.length > 0) {
|
||||
this.userList = data.length ? data : [];
|
||||
}
|
||||
this.initiateTable();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
});
|
||||
},
|
||||
editModule(module) {
|
||||
// Check if the user ID exists
|
||||
if (module.settingId) {
|
||||
// Redirect the user to the edit user page
|
||||
window.location.href = 'ModuleSetting/' + module.settingId;
|
||||
} else {
|
||||
console.error('Module ID not found');
|
||||
}
|
||||
},
|
||||
deleteModule(module) {
|
||||
this.selectedModule = module; // Set selected user
|
||||
$('#confirm-dialog').modal('show'); // Show the modal
|
||||
|
||||
// console.log(this.selectedModule);
|
||||
},
|
||||
confirmDelete(module) {
|
||||
fetch(`/ModuleAPI/DeleteModule/${module.settingId}`, {
|
||||
method: 'POST'
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to delete module');
|
||||
}
|
||||
// Remove the deleted user from the userData array
|
||||
const index = this.moduleData.findIndex(u => u.settingId === module.settingId);
|
||||
if (index !== -1) {
|
||||
alert("Module deleted successfully");
|
||||
this.moduleData.splice(index, 1);
|
||||
}
|
||||
this.hideModal(); // Hide the modal after deletion
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Failed to delete module with status:', error);
|
||||
});
|
||||
},
|
||||
hideModal() {
|
||||
$('#confirm-dialog').modal('hide');
|
||||
},
|
||||
initiateTable() {
|
||||
self = this;
|
||||
this.itemDatatable = $('#userDatatable').DataTable({
|
||||
"data": this.items,
|
||||
"columns": [
|
||||
{
|
||||
"title": "Unique Id",
|
||||
"data": "uniqueID",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
// Assign a unique ID to the <td> element
|
||||
$(td).attr('id', `qr${cellData}`);
|
||||
},
|
||||
},
|
||||
{
|
||||
"title": "Serial Number",
|
||||
"data": "serialNumber",
|
||||
},
|
||||
{
|
||||
"title": "Quantity",
|
||||
"data": "quantity",
|
||||
},
|
||||
{
|
||||
"title": "Supplier",
|
||||
"data": "supplier",
|
||||
},
|
||||
{
|
||||
"title": "Purchase Date",
|
||||
"data": "purchaseDate",
|
||||
},
|
||||
{
|
||||
"title": "Price After Convert(RM)",
|
||||
"data": "convertPrice",
|
||||
},
|
||||
{
|
||||
"title": "Invoice Date",
|
||||
"data": "invoiceDate",
|
||||
},
|
||||
{
|
||||
"title": "Warranty Until",
|
||||
"data": "warranty",
|
||||
"render": function (data, type, full, meta) {
|
||||
if (data > 0) { return full.endWDate }
|
||||
else { return data }
|
||||
}
|
||||
},
|
||||
// {
|
||||
// "title": "Image",
|
||||
// "data": "imageProduct",
|
||||
// "render": function (data, type, full, meta) {
|
||||
// var image = `<a href="${data}" target="_blank" data-lightbox="image-1">
|
||||
// <img src="${data}" alt="Image" class="img-thumbnail" style="width: 100px; height: 100px;" />
|
||||
// </a>`;
|
||||
// return image;
|
||||
// },
|
||||
// },
|
||||
{
|
||||
"title": "Print",
|
||||
"data": "uniqueID",
|
||||
"render": function (data) {
|
||||
var printButton = `<button type="button" class="btn btn-success print-btn" data-id="${data}">Print</button>`;
|
||||
return printButton;
|
||||
},
|
||||
},
|
||||
{
|
||||
"title": "Delete",
|
||||
"data": "productId",
|
||||
"render": function (data) {
|
||||
var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`;
|
||||
return deleteButton;
|
||||
},
|
||||
}
|
||||
],
|
||||
responsive: true,
|
||||
drawCallback: function (settings) {
|
||||
// Generate QR codes after rows are rendered
|
||||
const api = this.api();
|
||||
api.rows().every(function () {
|
||||
const data = this.data(); // Row data
|
||||
const containerId = `qr${data.uniqueID}`;
|
||||
const container = $(`#${containerId}`);
|
||||
// console.log(container[0]);
|
||||
if (container) {
|
||||
// Generate QR code only if not already generated
|
||||
new QRCode(container[0], {
|
||||
text: data.qrString,
|
||||
width: 150,
|
||||
height: 150,
|
||||
colorDark: "#000000",
|
||||
colorLight: "#ffffff",
|
||||
correctLevel: QRCode.CorrectLevel.H
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
})
|
||||
|
||||
// Attach click event listener to the delete buttons
|
||||
$('#itemDatatable tbody').on('click', '.delete-btn', function () {
|
||||
const itemId = $(this).data('id');
|
||||
self.deleteItem(itemId);
|
||||
});
|
||||
|
||||
$('#itemDatatable tbody').on('click', '.print-btn', function () {
|
||||
const itemId = $(this).data('id');
|
||||
var $row = $(this).closest('tr'); // get the row containing the button
|
||||
var imageSrc = $row.find('img').attr('src'); // find the img element in the row and get its src
|
||||
// console.log(imageSrc);
|
||||
self.printItem(itemId, imageSrc);
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
$(function () {
|
||||
app.mount('#app');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
@*
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
@ -730,38 +726,6 @@
|
||||
<!-- Datatables JS-->
|
||||
<script src="~/lib/datatables/datatables.js"></script>
|
||||
@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>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user