Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d75a43d45f | |||
| c5a0992b5d | |||
| 09d86835a2 | |||
| d1d2d55352 | |||
| c626f56cdb | |||
| 263e2ea9c0 | |||
| e5f6aa15b9 | |||
| 4e12b03e4b |
@@ -600,6 +600,5 @@ public class AppDBContext(DbContextOptions<AppDBContext> options) : DbContext(op
|
||||
Seed.ProcurementSeed.Apply(modelBuilder);
|
||||
Seed.CommerceSeed.Apply(modelBuilder);
|
||||
Seed.OperationsExtrasSeed.Apply(modelBuilder);
|
||||
Seed.AdminSeed.Apply(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Data.Seed;
|
||||
|
||||
public static class AdminSeed
|
||||
{
|
||||
private static readonly DateTime SeedDate = new(2026, 10, 13);
|
||||
|
||||
// Same GUID as the AuthHex user — the sub claim from the JWT maps to this Id
|
||||
internal static readonly Guid SuperAdminUserId = new("00000001-0000-0000-0000-000000000001");
|
||||
|
||||
public static void Apply(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>().HasData(new User
|
||||
{
|
||||
Id = SuperAdminUserId,
|
||||
Username = "superadmin",
|
||||
FullName = "Super Admin",
|
||||
FK_RoleId = RoleAndPermissionSeed.SuperAdminRoleId,
|
||||
IsActive = true,
|
||||
CreatedAt = SeedDate
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,10 @@ public static class MasterDataSeed
|
||||
{
|
||||
private static readonly DateTime SeedDate = new(2026, 8, 20);
|
||||
|
||||
// Precomputed via PasswordHasher<User>().HashPassword(new User(), "Passw0rd!123") — see
|
||||
// Implementation Notes in the plan; not derivable from HasData at migration time.
|
||||
internal const string SeedPasswordHash = "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==";
|
||||
|
||||
// Role ids match Data/Seed/RoleAndPermissionSeed.cs (private there, so re-declared here by value).
|
||||
internal static readonly Guid SalesRepRoleId = new("10000000-0000-0000-0000-000000000001");
|
||||
internal static readonly Guid SupervisorRoleId = new("10000000-0000-0000-0000-000000000002");
|
||||
@@ -111,12 +115,12 @@ public static class MasterDataSeed
|
||||
);
|
||||
|
||||
modelBuilder.Entity<User>().HasData(
|
||||
new User { Id = Supervisor1UserId, Username = "sunil.fernando",FullName = "Sunil Fernando", FK_RoleId = SupervisorRoleId, FK_ReportsToUserId = null, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = SalesRep1UserId, Username = "nimal.perera",FullName = "Nimal Perera", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = SalesRep2UserId, Username = "kamal.silva",FullName = "Kamal Silva", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = Driver1UserId, Username = "ruwan.jayasuriya",FullName = "Ruwan Jayasuriya", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = Driver2UserId, Username = "priyantha.kumara",FullName = "Priyantha Kumara", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = RegionalManager1UserId, Username = "priya.rajapaksa",FullName = "Priya Rajapaksa", FK_RoleId = RegionalManagerRoleId, FK_ReportsToUserId = null, CreatedAt = SeedDate, IsActive = true }
|
||||
new User { Id = Supervisor1UserId, Username = "sunil.fernando", PasswordHash = SeedPasswordHash, FullName = "Sunil Fernando", FK_RoleId = SupervisorRoleId, FK_ReportsToUserId = null, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = SalesRep1UserId, Username = "nimal.perera", PasswordHash = SeedPasswordHash, FullName = "Nimal Perera", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = SalesRep2UserId, Username = "kamal.silva", PasswordHash = SeedPasswordHash, FullName = "Kamal Silva", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = Driver1UserId, Username = "ruwan.jayasuriya", PasswordHash = SeedPasswordHash, FullName = "Ruwan Jayasuriya", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = Driver2UserId, Username = "priyantha.kumara", PasswordHash = SeedPasswordHash, FullName = "Priyantha Kumara", FK_RoleId = SalesRepRoleId, FK_ReportsToUserId = Supervisor1UserId, CreatedAt = SeedDate, IsActive = true },
|
||||
new User { Id = RegionalManager1UserId, Username = "priya.rajapaksa", PasswordHash = SeedPasswordHash, FullName = "Priya Rajapaksa", FK_RoleId = RegionalManagerRoleId, FK_ReportsToUserId = null, CreatedAt = SeedDate, IsActive = true }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<DriverProfile>().HasData(
|
||||
|
||||
@@ -43,7 +43,7 @@ public static class OperationsExtrasSeed
|
||||
public static void Apply(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>().HasData(
|
||||
new User { Id = RegionalAgency1UserId, Username = "channa.desilva", FullName = "Channa De Silva", FK_RoleId = RegionalAgencyRoleId, FK_ReportsToUserId = null, CreatedAt = new DateTime(2026, 8, 20), IsActive = true }
|
||||
new User { Id = RegionalAgency1UserId, Username = "channa.desilva", PasswordHash = MasterDataSeed.SeedPasswordHash, FullName = "Channa De Silva", FK_RoleId = RegionalAgencyRoleId, FK_ReportsToUserId = null, CreatedAt = new DateTime(2026, 8, 20), IsActive = true }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<Uom>().HasData(
|
||||
|
||||
@@ -7,191 +7,22 @@ public static class RoleAndPermissionSeed
|
||||
{
|
||||
private static readonly DateTime SeedDate = new(2026, 8, 18);
|
||||
|
||||
private static readonly Guid SalesRepId = new("10000000-0000-0000-0000-000000000001");
|
||||
private static readonly Guid SupervisorId = new("10000000-0000-0000-0000-000000000002");
|
||||
private static readonly Guid AreaManagerId = new("10000000-0000-0000-0000-000000000003");
|
||||
private static readonly Guid AreaSupervisorId = new("10000000-0000-0000-0000-000000000004");
|
||||
private static readonly Guid RegionalManagerId = new("10000000-0000-0000-0000-000000000005");
|
||||
private static readonly Guid RegionalAgencyId = new("10000000-0000-0000-0000-000000000006");
|
||||
internal static readonly Guid SuperAdminRoleId = new("10000000-0000-0000-0000-000000000007");
|
||||
|
||||
// ── Legacy broad permissions (nav.ts uses these for sidebar visibility) ────
|
||||
private static readonly Guid PermOrdersView = new("20000000-0000-0000-0000-000000000001");
|
||||
private static readonly Guid PermRidesView = new("20000000-0000-0000-0000-000000000002");
|
||||
private static readonly Guid PermLoadingView = new("20000000-0000-0000-0000-000000000003");
|
||||
private static readonly Guid PermStoresView = new("20000000-0000-0000-0000-000000000004");
|
||||
private static readonly Guid PermSalesVisitsCheckin = new("20000000-0000-0000-0000-000000000005");
|
||||
private static readonly Guid PermItemsView = new("20000000-0000-0000-0000-000000000006");
|
||||
private static readonly Guid PermCategoriesView = new("20000000-0000-0000-0000-000000000007");
|
||||
private static readonly Guid PermWarehousesView = new("20000000-0000-0000-0000-000000000008");
|
||||
private static readonly Guid PermPurchaseOrdersView = new("20000000-0000-0000-0000-000000000009");
|
||||
private static readonly Guid PermPricelistsView = new("20000000-0000-0000-0000-000000000010");
|
||||
private static readonly Guid PermSchemesView = new("20000000-0000-0000-0000-000000000011");
|
||||
private static readonly Guid PermSuppliersView = new("20000000-0000-0000-0000-000000000012");
|
||||
private static readonly Guid PermDriverProfilesView = new("20000000-0000-0000-0000-000000000013");
|
||||
private static readonly Guid PermComplianceManage = new("20000000-0000-0000-0000-000000000014");
|
||||
private static readonly Guid PermUsersView = new("20000000-0000-0000-0000-000000000015");
|
||||
private static readonly Guid PermRolesView = new("20000000-0000-0000-0000-000000000016");
|
||||
private static readonly Guid PermRegionsView = new("20000000-0000-0000-0000-000000000017");
|
||||
private static readonly Guid PermRoutesView = new("20000000-0000-0000-0000-000000000018");
|
||||
private static readonly Guid PermVehiclesView = new("20000000-0000-0000-0000-000000000019");
|
||||
|
||||
// ── Granular API permissions (used in [Authorize("...")] on controller actions) ─
|
||||
private static readonly Guid PermClaimView = new("20000000-0000-0000-0000-000000000020");
|
||||
private static readonly Guid PermClaimManage = new("20000000-0000-0000-0000-000000000021");
|
||||
private static readonly Guid PermDeliveryTaskView = new("20000000-0000-0000-0000-000000000022");
|
||||
private static readonly Guid PermDeliveryTaskManage = new("20000000-0000-0000-0000-000000000023");
|
||||
private static readonly Guid PermDriverView = new("20000000-0000-0000-0000-000000000024");
|
||||
private static readonly Guid PermDriverManage = new("20000000-0000-0000-0000-000000000025");
|
||||
private static readonly Guid PermGrnView = new("20000000-0000-0000-0000-000000000026");
|
||||
private static readonly Guid PermGrnManage = new("20000000-0000-0000-0000-000000000027");
|
||||
private static readonly Guid PermLoadingSheetView = new("20000000-0000-0000-0000-000000000028");
|
||||
private static readonly Guid PermLoadingSheetManage = new("20000000-0000-0000-0000-000000000029");
|
||||
private static readonly Guid PermPriceListView = new("20000000-0000-0000-0000-000000000030");
|
||||
private static readonly Guid PermPriceListManage = new("20000000-0000-0000-0000-000000000031");
|
||||
private static readonly Guid PermPurchaseOrderView = new("20000000-0000-0000-0000-000000000032");
|
||||
private static readonly Guid PermPurchaseOrderManage= new("20000000-0000-0000-0000-000000000033");
|
||||
private static readonly Guid PermPurchaseReturnManage=new("20000000-0000-0000-0000-000000000034");
|
||||
private static readonly Guid PermRegionView = new("20000000-0000-0000-0000-000000000035");
|
||||
private static readonly Guid PermRegionManage = new("20000000-0000-0000-0000-000000000036");
|
||||
private static readonly Guid PermReturnView = new("20000000-0000-0000-0000-000000000037");
|
||||
private static readonly Guid PermReturnManage = new("20000000-0000-0000-0000-000000000038");
|
||||
private static readonly Guid PermRouteView = new("20000000-0000-0000-0000-000000000039");
|
||||
private static readonly Guid PermRouteManage = new("20000000-0000-0000-0000-000000000040");
|
||||
private static readonly Guid PermSchemeView = new("20000000-0000-0000-0000-000000000041");
|
||||
private static readonly Guid PermSchemeManage = new("20000000-0000-0000-0000-000000000042");
|
||||
private static readonly Guid PermStockView = new("20000000-0000-0000-0000-000000000043");
|
||||
private static readonly Guid PermStockManage = new("20000000-0000-0000-0000-000000000044");
|
||||
private static readonly Guid PermStoreView = new("20000000-0000-0000-0000-000000000045");
|
||||
private static readonly Guid PermStoreManage = new("20000000-0000-0000-0000-000000000046");
|
||||
private static readonly Guid PermSupplierClaimView = new("20000000-0000-0000-0000-000000000047");
|
||||
private static readonly Guid PermSupplierClaimManage= new("20000000-0000-0000-0000-000000000048");
|
||||
private static readonly Guid PermSysConfigView = new("20000000-0000-0000-0000-000000000049");
|
||||
private static readonly Guid PermSysConfigManage = new("20000000-0000-0000-0000-000000000050");
|
||||
private static readonly Guid SalesRepId = new("10000000-0000-0000-0000-000000000001");
|
||||
private static readonly Guid SupervisorId = new("10000000-0000-0000-0000-000000000002");
|
||||
private static readonly Guid AreaManagerId = new("10000000-0000-0000-0000-000000000003");
|
||||
private static readonly Guid AreaSupervisorId = new("10000000-0000-0000-0000-000000000004");
|
||||
private static readonly Guid RegionalManagerId = new("10000000-0000-0000-0000-000000000005");
|
||||
private static readonly Guid RegionalAgencyId = new("10000000-0000-0000-0000-000000000006");
|
||||
|
||||
public static void Apply(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Role>().HasData(
|
||||
new Role { Id = SalesRepId, Name = "SalesRep", Level = 10, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = SupervisorId, Name = "Supervisor", Level = 20, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = AreaManagerId, Name = "AreaManager", Level = 30, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = AreaSupervisorId, Name = "AreaSupervisor", Level = 40, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = RegionalManagerId,Name = "RegionalManager",Level = 50, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = RegionalAgencyId, Name = "RegionalAgency", Level = 60, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = SuperAdminRoleId, Name = "SuperAdmin", Level = 100, CreatedAt = SeedDate, IsActive = true }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<Permission>().HasData(
|
||||
// ── Legacy broad permissions ──────────────────────────────────────────
|
||||
new Permission { Id = PermOrdersView, Code = "orders.view", Description = "View shop POs, invoices, payments and returns", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRidesView, Code = "rides.view", Description = "View and manage delivery rides and delivery tasks", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermLoadingView, Code = "loading.view", Description = "View and manage loading sheets", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermStoresView, Code = "stores.view", Description = "View store accounts, credit limits and balances", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSalesVisitsCheckin, Code = "sales_visits.checkin", Description = "Check in and out of scheduled store visits", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermItemsView, Code = "items.view", Description = "View and manage catalogue products", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermCategoriesView, Code = "categories.view", Description = "View and manage product categories and brands", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermWarehousesView, Code = "warehouses.view", Description = "View stock balances, movements, warehouses and reports", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPurchaseOrdersView, Code = "purchase_orders.view", Description = "View and manage purchase orders, GRNs and supplier claims", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPricelistsView, Code = "pricelists.view", Description = "View and manage regional price lists", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSchemesView, Code = "schemes.view", Description = "View and manage pricing schemes and promotions", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSuppliersView, Code = "suppliers.view", Description = "View and manage supplier accounts", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermDriverProfilesView, Code = "driver_profiles.view", Description = "View and manage driver profiles and licensing", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermComplianceManage, Code = "compliance.manage", Description = "Manage driver compliance rules", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermUsersView, Code = "users.view", Description = "View and manage staff user accounts", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRolesView, Code = "roles.view", Description = "View and manage roles and their permission sets", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRegionsView, Code = "regions.view", Description = "View and manage regions and region configuration", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRoutesView, Code = "routes.view", Description = "View and manage delivery routes", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermVehiclesView, Code = "vehicles.view", Description = "View and manage fleet vehicles", CreatedAt = SeedDate, IsActive = true },
|
||||
|
||||
// ── Granular API permissions ──────────────────────────────────────────
|
||||
new Permission { Id = PermClaimView, Code = "claim.view", Description = "View agency claims and settlement status", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermClaimManage, Code = "claim.manage", Description = "Create and settle agency claims", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermDeliveryTaskView, Code = "delivery-task.view", Description = "View delivery tasks within a ride", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermDeliveryTaskManage, Code = "delivery-task.manage", Description = "Confirm and fail delivery tasks", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermDriverView, Code = "driver.view", Description = "View driver profiles and license details", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermDriverManage, Code = "driver.manage", Description = "Create and update driver profiles", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermGrnView, Code = "grn.view", Description = "View goods receipt notes", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermGrnManage, Code = "grn.manage", Description = "Create and confirm goods receipts", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermLoadingSheetView, Code = "loading-sheet.view", Description = "View loading sheets and their items", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermLoadingSheetManage, Code = "loading-sheet.manage", Description = "Create, edit, and confirm loading sheets", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPriceListView, Code = "price-list.view", Description = "View regional price lists", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPriceListManage, Code = "price-list.manage", Description = "Create and manage item price lists", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPurchaseOrderView, Code = "purchase-order.view", Description = "View purchase orders and line items", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPurchaseOrderManage,Code = "purchase-order.manage", Description = "Create, confirm, and close purchase orders", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermPurchaseReturnManage,Code= "purchase-return.manage",Description = "Create and manage purchase returns to suppliers", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRegionView, Code = "region.view", Description = "View regions and their configuration", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRegionManage, Code = "region.manage", Description = "Create and update regions, targets, and budgets", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermReturnView, Code = "return.view", Description = "View order returns", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermReturnManage, Code = "return.manage", Description = "Create and manage order returns", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRouteView, Code = "route.view", Description = "View delivery routes", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermRouteManage, Code = "route.manage", Description = "Create and manage delivery routes", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSchemeView, Code = "scheme.view", Description = "View pricing schemes and promotions", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSchemeManage, Code = "scheme.manage", Description = "Create and configure pricing schemes", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermStockView, Code = "stock.view", Description = "View stock balances and movements", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermStockManage, Code = "stock.manage", Description = "Transfer stock and record damage or adjustments", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermStoreView, Code = "store.view", Description = "View store accounts and balances", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermStoreManage, Code = "store.manage", Description = "Create and update store accounts", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSupplierClaimView, Code = "supplier-claim.view", Description = "View supplier claims", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSupplierClaimManage,Code = "supplier-claim.manage", Description = "Create and resolve supplier claims", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSysConfigView, Code = "sys-config.view", Description = "View system configuration settings", CreatedAt = SeedDate, IsActive = true },
|
||||
new Permission { Id = PermSysConfigManage, Code = "sys-config.manage", Description = "Update system configuration settings", CreatedAt = SeedDate, IsActive = true }
|
||||
);
|
||||
|
||||
// SuperAdmin gets every permission
|
||||
modelBuilder.Entity<RolePermission>().HasData(
|
||||
// ── Legacy broad permissions ──────────────────────────────────────────
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermOrdersView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRidesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermLoadingView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermStoresView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSalesVisitsCheckin, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermItemsView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermCategoriesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermWarehousesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPurchaseOrdersView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPricelistsView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSchemesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSuppliersView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermDriverProfilesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermComplianceManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermUsersView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRolesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRegionsView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRoutesView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermVehiclesView, CreatedAt = SeedDate, IsActive = true },
|
||||
|
||||
// ── Granular API permissions ──────────────────────────────────────────
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermClaimView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermClaimManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermDeliveryTaskView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermDeliveryTaskManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermDriverView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermDriverManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermGrnView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermGrnManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermLoadingSheetView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermLoadingSheetManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPriceListView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPriceListManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPurchaseOrderView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPurchaseOrderManage,CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermPurchaseReturnManage,CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRegionView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRegionManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermReturnView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermReturnManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRouteView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermRouteManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSchemeView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSchemeManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermStockView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermStockManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermStoreView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermStoreManage, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSupplierClaimView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSupplierClaimManage,CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSysConfigView, CreatedAt = SeedDate, IsActive = true },
|
||||
new RolePermission { FK_RoleId = SuperAdminRoleId, FK_PermissionId = PermSysConfigManage, CreatedAt = SeedDate, IsActive = true }
|
||||
new Role { Id = SalesRepId, Name = "SalesRep", Level = 10, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = SupervisorId, Name = "Supervisor", Level = 20, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = AreaManagerId, Name = "AreaManager", Level = 30, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = AreaSupervisorId, Name = "AreaSupervisor", Level = 40, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = RegionalManagerId, Name = "RegionalManager", Level = 50, CreatedAt = SeedDate, IsActive = true },
|
||||
new Role { Id = RegionalAgencyId, Name = "RegionalAgency", Level = 60, CreatedAt = SeedDate, IsActive = true }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using Distribution.Features.User;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -8,93 +6,32 @@ namespace Distribution.Features.Auth;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/auth")]
|
||||
public class AuthController(AuthService service, ICurrentUserService currentUser, IUserRepository userRepo) : ControllerBase
|
||||
public class AuthController(AuthService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
private static IActionResult ToActionResult(AuthHexResponse result) =>
|
||||
result.Success ? new OkObjectResult(result) : new ObjectResult(result) { StatusCode = result.StatusCode is >= 400 and < 600 ? result.StatusCode : 401 };
|
||||
|
||||
[HttpPost("login")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Login(LoginRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.LoginAsync(request, ct);
|
||||
|
||||
if (!result.Success || result.Data is not { } data)
|
||||
return ToActionResult(result);
|
||||
|
||||
string? token = null;
|
||||
TimeSpan maxAge = TimeSpan.FromHours(1);
|
||||
|
||||
if (data.TryGetProperty("accessToken", out var tokenEl))
|
||||
token = tokenEl.GetString();
|
||||
|
||||
if (data.TryGetProperty("expiresIn", out var expEl))
|
||||
maxAge = TimeSpan.FromSeconds(expEl.GetInt32());
|
||||
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
Response.Cookies.Append("access-token", token, new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Path = "/",
|
||||
MaxAge = maxAge,
|
||||
Secure = Request.IsHttps,
|
||||
});
|
||||
}
|
||||
|
||||
MeResponse? profile = null;
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
var jwt = new JwtSecurityTokenHandler().ReadJwtToken(token);
|
||||
var userIdStr = jwt.Claims.FirstOrDefault(c => c.Type == "UserId")?.Value;
|
||||
if (Guid.TryParse(userIdStr, out var userId))
|
||||
{
|
||||
var user = await userRepo.GetByIdAsync(userId);
|
||||
if (user is not null)
|
||||
profile = new MeResponse(
|
||||
user.Id,
|
||||
user.Username,
|
||||
user.FK_RoleId,
|
||||
user.Role?.Name ?? string.Empty,
|
||||
user.Role?.Level ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(new { result.StatusCode, result.Success, result.Message, result.Data, profile });
|
||||
}
|
||||
public async Task<IActionResult> Login(LoginRequest request, CancellationToken ct) =>
|
||||
ToActionResult(await service.LoginAsync(request, ct));
|
||||
|
||||
[HttpPost("register")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Register(RegisterRequest request, CancellationToken ct) =>
|
||||
ToActionResult(await service.RegisterAsync(request, ct));
|
||||
|
||||
[HttpGet("me")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Me()
|
||||
public async Task<IActionResult> Me(CancellationToken ct)
|
||||
{
|
||||
if (currentUser.UserId is null) return Unauthorized();
|
||||
var user = await userRepo.GetByIdAsync(currentUser.UserId.Value);
|
||||
if (user is null) return Unauthorized();
|
||||
return Ok(new MeResponse(
|
||||
user.Id,
|
||||
user.Username,
|
||||
user.FK_RoleId,
|
||||
user.Role?.Name ?? string.Empty,
|
||||
user.Role?.Level ?? 0));
|
||||
var userId = currentUser.UserId ?? throw new UnauthorizedAccessException();
|
||||
return ToActionResult(await service.GetUserDetailsAsync(userId, ct));
|
||||
}
|
||||
|
||||
[HttpPost("logout")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Logout()
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Logout(CancellationToken ct)
|
||||
{
|
||||
Response.Cookies.Delete("access-token", new CookieOptions
|
||||
{
|
||||
HttpOnly = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Path = "/",
|
||||
Secure = Request.IsHttps,
|
||||
});
|
||||
return Ok(new { success = true });
|
||||
var token = Request.Headers.Authorization.ToString().Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase);
|
||||
return ToActionResult(await service.LogoutAsync(token, ct));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
namespace Distribution.Features.Auth;
|
||||
|
||||
public record LoginRequest(
|
||||
string Identifier,
|
||||
string Password,
|
||||
Guid? UserTypeId = null,
|
||||
string DeviceName = "Unknown Device");
|
||||
public record LoginRequest(string Username, string Password);
|
||||
|
||||
public record RegisterRequest(string Username, string email, string Password, string? FullName);
|
||||
|
||||
public record MeResponse(
|
||||
Guid UserId,
|
||||
string Username,
|
||||
Guid RoleId,
|
||||
string RoleCode,
|
||||
int RoleLevel);
|
||||
public record RegisterRequest(string Username, string Password, string? FullName);
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
|
||||
namespace Distribution.Features.Auth;
|
||||
|
||||
/// <summary>
|
||||
/// Own-user auth is fully delegated to AuthHex — this service only proxies the four functions
|
||||
/// AuthHex exposes (loginUser/registerUser/getUserDetails/LogoutUser). No local password check or
|
||||
/// token issuance happens here; AuthHex owns credentials and signs the JWT this app validates.
|
||||
/// token issuance happens here; AuthHex owns credentials and signs the JWT this app validates
|
||||
/// (see Program.cs's JwtBearer registration + OnTokenValidated role mapping).
|
||||
/// </summary>
|
||||
public class AuthService(IAuthHexClient authHex)
|
||||
{
|
||||
public Task<AuthHexResponse> LoginAsync(LoginRequest request, CancellationToken ct = default) =>
|
||||
authHex.CallAsync("loginUser", new
|
||||
{
|
||||
identifier = request.Identifier,
|
||||
password = request.Password,
|
||||
userTypeId = request.UserTypeId,
|
||||
deviceName = request.DeviceName
|
||||
}, reference: Guid.NewGuid().ToString(), ct: ct);
|
||||
authHex.CallAsync("loginUser", request, reference: Guid.NewGuid().ToString(), ct: ct);
|
||||
|
||||
public Task<AuthHexResponse> RegisterAsync(RegisterRequest request, CancellationToken ct = default) =>
|
||||
authHex.CallAsync("registerUser", request, reference: Guid.NewGuid().ToString(), ct: ct);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Distribution.Features.Auth;
|
||||
|
||||
/// <summary>
|
||||
/// Typed HttpClient that proxies requests to the external Auth Service.
|
||||
/// Registered via AddHttpClient<AuthServiceClient> in Program.cs.
|
||||
/// BaseAddress is configured from AuthService:BaseUrl in appsettings.json.
|
||||
///
|
||||
/// TODO: Implement methods once Auth Service contract is agreed.
|
||||
/// </summary>
|
||||
public class AuthServiceClient(HttpClient http) : IAuthServiceClient
|
||||
{
|
||||
// TODO: implement proxy methods, e.g.:
|
||||
//
|
||||
// public async Task<AuthServiceResponse?> LoginAsync(LoginRequest request, CancellationToken ct)
|
||||
// {
|
||||
// var response = await http.PostAsJsonAsync("/TODO_AUTH_SERVICE_LOGIN_PATH", request, ct);
|
||||
// if (!response.IsSuccessStatusCode) return null;
|
||||
// return await response.Content.ReadFromJsonAsync<AuthServiceResponse>(ct);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Distribution.Features.Auth;
|
||||
|
||||
public class AuthServiceOptions
|
||||
{
|
||||
public const string SectionName = "AuthService";
|
||||
|
||||
/// <summary>Base URL of the external Auth Service, e.g. "https://auth.internal".</summary>
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
|
||||
// TODO: add other config (API keys, timeout, etc.) once Auth Service is defined.
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Distribution.Features.Auth;
|
||||
|
||||
/// <summary>
|
||||
/// Connector to the external Auth Service. This backend proxies all auth
|
||||
/// traffic from the Next.js frontend through to the Auth Service — the
|
||||
/// frontend never calls the Auth Service directly.
|
||||
///
|
||||
/// TODO: Fill in the method signatures once the Auth Service contract is agreed.
|
||||
/// </summary>
|
||||
public interface IAuthServiceClient
|
||||
{
|
||||
// TODO: define methods based on Auth Service contract, e.g.:
|
||||
// Task<AuthServiceResponse?> LoginAsync(LoginRequest request, CancellationToken ct);
|
||||
// Task<AuthServiceResponse?> RefreshAsync(string refreshToken, CancellationToken ct);
|
||||
// Task LogoutAsync(string token, CancellationToken ct);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Claims;
|
||||
@@ -8,12 +7,10 @@ namespace Distribution.Features.Claims;
|
||||
public class ClaimController(ClaimService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/claims")]
|
||||
[Authorize("claim.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
[HttpGet("api/claims/{id:guid}")]
|
||||
[Authorize("claim.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -21,7 +18,6 @@ public class ClaimController(ClaimService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPost("api/claims")]
|
||||
[Authorize("claim.manage")]
|
||||
public async Task<IActionResult> Create(CreateClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -33,7 +29,6 @@ public class ClaimController(ClaimService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPut("api/claims/{id:guid}")]
|
||||
[Authorize("claim.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -45,7 +40,6 @@ public class ClaimController(ClaimService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPost("api/claims/{id:guid}/settle")]
|
||||
[Authorize("claim.manage")]
|
||||
public async Task<IActionResult> Settle(Guid id, SettleClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.SettledByUserId;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Models;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.DeliveryRide;
|
||||
|
||||
[ApiController]
|
||||
[Route("api")]
|
||||
public class DeliveryTaskController(DeliveryTaskService service) : ControllerBase
|
||||
public class DeliveryTaskController(DeliveryTaskService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpPost("rides/{rideId:guid}/tasks/generate")]
|
||||
[Authorize("delivery-task.manage")]
|
||||
public async Task<IActionResult> Generate(Guid rideId, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -23,7 +22,6 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
|
||||
[HttpGet("rides/{rideId:guid}/tasks")]
|
||||
[HttpGet("rides/{rideId:guid}/delivery-tasks")]
|
||||
[Authorize("delivery-task.view")]
|
||||
public async Task<IActionResult> GetByRide(Guid rideId)
|
||||
{
|
||||
var result = await service.GetByRideIdAsync(rideId);
|
||||
@@ -31,7 +29,6 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
}
|
||||
|
||||
[HttpGet("delivery-tasks")]
|
||||
//[Authorize("delivery-task.view")]
|
||||
public async Task<IActionResult> GetAll(
|
||||
[FromQuery] DeliveryTaskStatus? status,
|
||||
[FromQuery] int page = 1,
|
||||
@@ -42,7 +39,6 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
}
|
||||
|
||||
[HttpGet("delivery-tasks/{id:guid}")]
|
||||
[Authorize("delivery-task.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -50,7 +46,6 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
}
|
||||
|
||||
[HttpPut("delivery-tasks/{id:guid}/quantities")]
|
||||
[Authorize("delivery-task.manage")]
|
||||
public async Task<IActionResult> SetQuantities(Guid id, SetQuantitiesRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -63,12 +58,11 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
}
|
||||
|
||||
[HttpPost("delivery-tasks/{id:guid}/confirm")]
|
||||
[Authorize("delivery-task.manage")]
|
||||
public async Task<IActionResult> Confirm(Guid id, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await service.ConfirmAsync(id, ct);
|
||||
var result = await service.ConfirmAsync(id, currentUser.UserId ?? Guid.Empty, ct);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (KeyNotFoundException) { return NotFound(); }
|
||||
@@ -76,7 +70,6 @@ public class DeliveryTaskController(DeliveryTaskService service) : ControllerBas
|
||||
}
|
||||
|
||||
[HttpPost("delivery-tasks/{id:guid}/fail")]
|
||||
[Authorize("delivery-task.manage")]
|
||||
public async Task<IActionResult> Fail(Guid id, FailTaskRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -12,7 +12,7 @@ public class DeliveryTaskService(
|
||||
IRideRepository rideRepo,
|
||||
IShopPORepository shopPORepo,
|
||||
ILoadingSheetRepository loadingSheetRepo,
|
||||
IStockRepository stockRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
private static DeliveryTaskResponse ToResponse(DeliveryTask t) =>
|
||||
@@ -134,7 +134,7 @@ public class DeliveryTaskService(
|
||||
return ToResponse(saved!);
|
||||
}
|
||||
|
||||
public async Task<DeliveryTaskResponse> ConfirmAsync(Guid taskId, CancellationToken ct = default)
|
||||
public async Task<DeliveryTaskResponse> ConfirmAsync(Guid taskId, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
var task = await repo.GetByIdAsync(taskId)
|
||||
?? throw new KeyNotFoundException("Delivery task not found");
|
||||
@@ -166,29 +166,12 @@ public class DeliveryTaskService(
|
||||
{
|
||||
foreach (var item in task.ShopPO.Items.Where(i => i.QuantityFulfilled > 0))
|
||||
{
|
||||
var vehicleBalance = await stockRepo.GetBalanceAsync(item.FK_ItemId, vehicleId);
|
||||
var availableQuantity = vehicleBalance?.Quantity ?? 0;
|
||||
var itemName = item.Item?.Name ?? item.FK_ItemId.ToString();
|
||||
|
||||
if (availableQuantity < item.QuantityFulfilled)
|
||||
throw new InvalidOperationException(
|
||||
$"Insufficient vehicle stock for item '{itemName}': available {availableQuantity}, required {item.QuantityFulfilled}");
|
||||
|
||||
vehicleBalance!.Quantity -= item.QuantityFulfilled;
|
||||
vehicleBalance.UpdatedAt = DateTime.Now;
|
||||
stockRepo.UpdateBalance(vehicleBalance);
|
||||
|
||||
await stockRepo.AddMovementAsync(new StockMovement
|
||||
{
|
||||
FK_ItemId = item.FK_ItemId,
|
||||
FromLocationId = vehicleId,
|
||||
FromLocationType = LocationType.Vehicle,
|
||||
ToLocationId = StockService.ExternalLocationId,
|
||||
ToLocationType = LocationType.External,
|
||||
Quantity = item.QuantityFulfilled,
|
||||
Type = MovementType.Sale,
|
||||
ReferenceId = task.FK_ShopPOId
|
||||
});
|
||||
await mover.MoveAsync(item.FK_ItemId, itemName,
|
||||
vehicleId, LocationType.Vehicle,
|
||||
StockService.ExternalLocationId, LocationType.External,
|
||||
item.QuantityFulfilled, MovementType.Sale, task.FK_ShopPOId, userId);
|
||||
}
|
||||
|
||||
repo.Update(task);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Distribution.Features.DriverComplianceConfig;
|
||||
using Distribution.Features.DriverComplianceConfig;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.DriverProfile;
|
||||
@@ -13,7 +12,6 @@ public class DriverProfileController(
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("driver.view")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] int page = 1, [FromQuery] int pageSize = 20)
|
||||
{
|
||||
var result = await service.GetAllAsync(page, pageSize);
|
||||
@@ -21,7 +19,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("driver.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -29,7 +26,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("driver.manage")]
|
||||
public async Task<IActionResult> Create(CreateDriverProfileRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -48,7 +44,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("driver.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateDriverProfileRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateAsync(id, request, ct);
|
||||
@@ -56,7 +51,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("driver.manage")]
|
||||
public async Task<IActionResult> Deactivate(Guid id, CancellationToken ct)
|
||||
{
|
||||
var success = await service.DeactivateAsync(id, ct);
|
||||
@@ -64,7 +58,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpGet("compliance")]
|
||||
[Authorize("driver.view")]
|
||||
public async Task<IActionResult> GetCompliance()
|
||||
{
|
||||
var result = await complianceService.GetAsync();
|
||||
@@ -72,7 +65,6 @@ public class DriverProfileController(
|
||||
}
|
||||
|
||||
[HttpPut("compliance")]
|
||||
[Authorize("driver.manage")]
|
||||
public async Task<IActionResult> UpsertCompliance(UpdateDriverComplianceConfigRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? throw new UnauthorizedAccessException();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Grn;
|
||||
@@ -8,7 +7,6 @@ namespace Distribution.Features.Grn;
|
||||
public class GrnController(GrnService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/goods-receipts")]
|
||||
[Authorize("grn.view")]
|
||||
public async Task<IActionResult> GetAll(
|
||||
[FromQuery] Guid? purchaseOrderId,
|
||||
[FromQuery] int page = 1,
|
||||
@@ -19,7 +17,6 @@ public class GrnController(GrnService service, ICurrentUserService currentUser)
|
||||
}
|
||||
|
||||
[HttpGet("api/goods-receipts/{id:guid}")]
|
||||
[Authorize("grn.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -27,7 +24,6 @@ public class GrnController(GrnService service, ICurrentUserService currentUser)
|
||||
}
|
||||
|
||||
[HttpPost("api/goods-receipts")]
|
||||
[Authorize("grn.manage")]
|
||||
public async Task<IActionResult> CreateFlat(CreateFlatGrnRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
@@ -46,7 +42,6 @@ public class GrnController(GrnService service, ICurrentUserService currentUser)
|
||||
|
||||
/// <summary>Goods received without a purchase order.</summary>
|
||||
[HttpPost("api/goods-receipts/direct")]
|
||||
[Authorize("grn.manage")]
|
||||
public async Task<IActionResult> CreateDirect(CreateDirectGrnRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.ReceivedByUserId;
|
||||
@@ -60,12 +55,10 @@ public class GrnController(GrnService service, ICurrentUserService currentUser)
|
||||
}
|
||||
|
||||
[HttpGet("api/purchase-orders/{id:guid}/goods-receipts")]
|
||||
[Authorize("grn.view")]
|
||||
public async Task<IActionResult> GetByPurchaseOrder(Guid id) =>
|
||||
Ok(await service.GetByPurchaseOrderIdAsync(id));
|
||||
|
||||
[HttpPost("api/purchase-orders/{id:guid}/goods-receipts")]
|
||||
[Authorize("grn.manage")]
|
||||
public async Task<IActionResult> Create(Guid id, CreateGrnRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.ReceivedByUserId;
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.LoadingEvent;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/loading-sheets")]
|
||||
public class LoadingSheetController(
|
||||
LoadingSheetService service,
|
||||
IScopeAccessService scopeAccess,
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
public class LoadingSheetController(LoadingSheetService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
//[Authorize("loading-sheet.view")]
|
||||
public async Task<IActionResult> GetAll(
|
||||
[FromQuery] Guid? rideId,
|
||||
[FromQuery] LoadingSheetStatus? status,
|
||||
@@ -22,26 +17,11 @@ public class LoadingSheetController(
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
if (routeId.HasValue)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasRouteScopeAsync(userId.Value, routeId.Value))
|
||||
return StatusCode(403);
|
||||
}
|
||||
|
||||
if (regionId.HasValue)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasRegionScopeAsync(userId.Value, regionId.Value))
|
||||
return StatusCode(403);
|
||||
}
|
||||
|
||||
var result = await service.GetAllAsync(rideId, status, routeId, regionId, page, pageSize);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("loading-sheet.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -49,7 +29,6 @@ public class LoadingSheetController(
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("loading-sheet.manage")]
|
||||
public async Task<IActionResult> Create(CreateLoadingSheetRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
@@ -66,7 +45,6 @@ public class LoadingSheetController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/items")]
|
||||
[Authorize("loading-sheet.manage")]
|
||||
public async Task<IActionResult> SetItems(Guid id, SetItemsRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -79,7 +57,6 @@ public class LoadingSheetController(
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/confirm")]
|
||||
[Authorize("loading-sheet.manage")]
|
||||
public async Task<IActionResult> Confirm(Guid id, ConfirmLoadingSheetRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Distribution.Features.LoadingEvent;
|
||||
public class LoadingSheetService(
|
||||
ILoadingSheetRepository repo,
|
||||
IRideRepository rideRepo,
|
||||
IStockRepository stockRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
public async Task<PagedResponse<LoadingSheetResponse>> GetAllAsync(Guid? rideId, LoadingSheetStatus? status, Guid? routeId, Guid? regionId, int page, int pageSize)
|
||||
@@ -154,59 +154,14 @@ public class LoadingSheetService(
|
||||
|
||||
private async Task ApplyLoadMovementsAsync(Guid sheetId, Guid vehicleId, List<LoadingSheetItem> items, Guid userId)
|
||||
{
|
||||
// Vehicle balances created during this confirm are only tracked, not yet saved, so a
|
||||
// later row for the same item would not find them via the repository and would try to
|
||||
// insert a duplicate (item, vehicle) balance.
|
||||
var createdVehicleBalances = new Dictionary<Guid, StockBalance>();
|
||||
|
||||
foreach (var item in items.Where(i => i.QuantityDispatched > 0))
|
||||
{
|
||||
var warehouseBalance = await stockRepo.GetBalanceAsync(item.FK_ItemId, item.FK_WarehouseId)
|
||||
?? throw new InvalidOperationException(
|
||||
$"No stock found for '{item.Item?.Name ?? item.FK_ItemId.ToString()}' in warehouse '{item.Warehouse?.Name ?? item.FK_WarehouseId.ToString()}'");
|
||||
var label = $"{item.Item?.Name ?? item.FK_ItemId.ToString()} (warehouse {item.Warehouse?.Name ?? item.FK_WarehouseId.ToString()})";
|
||||
|
||||
if (warehouseBalance.Quantity < item.QuantityDispatched)
|
||||
throw new InvalidOperationException(
|
||||
$"Insufficient stock for '{item.Item?.Name ?? item.FK_ItemId.ToString()}' in warehouse '{item.Warehouse?.Name ?? item.FK_WarehouseId.ToString()}' " +
|
||||
$"(available {warehouseBalance.Quantity}, needed {item.QuantityDispatched})");
|
||||
|
||||
warehouseBalance.Quantity -= item.QuantityDispatched;
|
||||
warehouseBalance.UpdatedAt = DateTime.Now;
|
||||
stockRepo.UpdateBalance(warehouseBalance);
|
||||
|
||||
var vehicleBalance = createdVehicleBalances.GetValueOrDefault(item.FK_ItemId)
|
||||
?? await stockRepo.GetBalanceAsync(item.FK_ItemId, vehicleId);
|
||||
if (vehicleBalance is null)
|
||||
{
|
||||
var created = new StockBalance
|
||||
{
|
||||
FK_ItemId = item.FK_ItemId,
|
||||
LocationId = vehicleId,
|
||||
LocationType = LocationType.Vehicle,
|
||||
Quantity = item.QuantityDispatched
|
||||
};
|
||||
createdVehicleBalances[item.FK_ItemId] = created;
|
||||
await stockRepo.AddBalanceAsync(created);
|
||||
}
|
||||
else
|
||||
{
|
||||
vehicleBalance.Quantity += item.QuantityDispatched;
|
||||
vehicleBalance.UpdatedAt = DateTime.Now;
|
||||
stockRepo.UpdateBalance(vehicleBalance);
|
||||
}
|
||||
|
||||
await stockRepo.AddMovementAsync(new StockMovement
|
||||
{
|
||||
FK_ItemId = item.FK_ItemId,
|
||||
FromLocationId = item.FK_WarehouseId,
|
||||
FromLocationType = LocationType.Warehouse,
|
||||
ToLocationId = vehicleId,
|
||||
ToLocationType = LocationType.Vehicle,
|
||||
Quantity = item.QuantityDispatched,
|
||||
Type = MovementType.Load,
|
||||
ReferenceId = sheetId,
|
||||
CreatedBy = userId
|
||||
});
|
||||
await mover.MoveAsync(item.FK_ItemId, label,
|
||||
item.FK_WarehouseId, LocationType.Warehouse,
|
||||
vehicleId, LocationType.Vehicle,
|
||||
item.QuantityDispatched, MovementType.Load, sheetId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,16 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.PriceList;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/price-lists")]
|
||||
public class PriceListController(
|
||||
PriceListService service,
|
||||
IScopeAccessService scopeAccess,
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
public class PriceListController(PriceListService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("price-list.view")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] Guid? regionId)
|
||||
{
|
||||
if (regionId.HasValue)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasRegionScopeAsync(userId.Value, regionId.Value))
|
||||
return StatusCode(403);
|
||||
}
|
||||
return Ok(await service.GetAllAsync(regionId));
|
||||
}
|
||||
public async Task<IActionResult> GetAll([FromQuery] Guid? regionId) =>
|
||||
Ok(await service.GetAllAsync(regionId));
|
||||
|
||||
[HttpGet("resolve")]
|
||||
[Authorize("price-list.view")]
|
||||
public async Task<IActionResult> Resolve([FromQuery] Guid itemId, [FromQuery] Guid storeId, [FromQuery] DateTime saleDate)
|
||||
{
|
||||
var result = await service.ResolveByStoreAsync(itemId, storeId, saleDate);
|
||||
@@ -33,7 +18,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("price-list.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -41,7 +25,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("price-list.manage")]
|
||||
public async Task<IActionResult> Create(CreatePriceListRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.CreateAsync(request, ct);
|
||||
@@ -49,7 +32,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("price-list.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdatePriceListRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -64,7 +46,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("price-list.manage")]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteAsync(id, ct);
|
||||
@@ -72,7 +53,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/items/{sku}")]
|
||||
[Authorize("price-list.manage")]
|
||||
public async Task<IActionResult> UpsertItem(Guid id, string sku, UpsertPriceListItemRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -87,7 +67,6 @@ public class PriceListController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}/items/{sku}")]
|
||||
[Authorize("price-list.manage")]
|
||||
public async Task<IActionResult> RemoveItem(Guid id, string sku, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Po;
|
||||
@@ -10,12 +9,10 @@ namespace Distribution.Features.Po;
|
||||
public class PoController(PoService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("purchase-order.view")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] Guid? supplierId, [FromQuery] PurchaseOrderStatus? status) =>
|
||||
Ok(await service.GetAllAsync(supplierId, status));
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("purchase-order.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -23,7 +20,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> Create(CreatePoRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
@@ -39,7 +35,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdatePoRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -51,7 +46,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/close")]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> Close(Guid id, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -63,7 +57,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/cancel")]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> Cancel(Guid id, CancelPoRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -75,7 +68,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/items/{itemId:guid}/cancel")]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> CancelLine(Guid id, Guid itemId, CancelPoLineRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -87,7 +79,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/match-invoice")]
|
||||
[Authorize("purchase-order.view")]
|
||||
public async Task<IActionResult> MatchInvoice(Guid id, [FromQuery] Guid? invoiceId, [FromQuery] Guid? grnId)
|
||||
{
|
||||
var result = await service.MatchInvoiceToPoAsync(id, invoiceId, grnId);
|
||||
@@ -95,7 +86,6 @@ public class PoController(PoService service, ICurrentUserService currentUser) :
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/resolve-variance")]
|
||||
[Authorize("purchase-order.manage")]
|
||||
public async Task<IActionResult> ResolveVariance(Guid id, ResolveInvoiceVarianceRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.PurchaseReturn;
|
||||
@@ -8,7 +7,6 @@ namespace Distribution.Features.PurchaseReturn;
|
||||
public class PurchaseReturnController(PurchaseReturnService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/purchase-returns/{id:guid}")]
|
||||
[Authorize("purchase-order.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -16,12 +14,10 @@ public class PurchaseReturnController(PurchaseReturnService service, ICurrentUse
|
||||
}
|
||||
|
||||
[HttpGet("api/purchase-orders/{id:guid}/returns")]
|
||||
[Authorize("purchase-order.view")]
|
||||
public async Task<IActionResult> GetByPurchaseOrder(Guid id) =>
|
||||
Ok(await service.GetByPurchaseOrderIdAsync(id));
|
||||
|
||||
[HttpPost("api/purchase-orders/{id:guid}/returns")]
|
||||
[Authorize("purchase-return.manage")]
|
||||
public async Task<IActionResult> Create(Guid id, CreatePurchaseReturnRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
|
||||
@@ -10,7 +10,7 @@ public class PurchaseReturnService(
|
||||
IPurchaseReturnRepository repo,
|
||||
IPoRepository poRepo,
|
||||
IGrnRepository goodsReceiptRepo,
|
||||
IStockRepository stockRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
private static PurchaseReturnItemResponse MapItem(Models.PurchaseReturnItem i) =>
|
||||
@@ -89,29 +89,12 @@ public class PurchaseReturnService(
|
||||
|
||||
foreach (var line in purchaseReturn.Items)
|
||||
{
|
||||
var balance = await stockRepo.GetBalanceAsync(line.FK_ItemId, warehouseId)
|
||||
?? throw new InvalidOperationException($"No stock balance found for item {line.FK_ItemId} at the receiving warehouse.");
|
||||
var itemName = po.Items.FirstOrDefault(i => i.FK_ItemId == line.FK_ItemId)?.Item?.Name ?? line.FK_ItemId.ToString();
|
||||
|
||||
if (balance.Quantity < line.Quantity)
|
||||
throw new InvalidOperationException($"Insufficient warehouse stock for item {line.FK_ItemId} to return.");
|
||||
|
||||
balance.Quantity -= line.Quantity;
|
||||
balance.UpdatedAt = DateTime.Now;
|
||||
stockRepo.UpdateBalance(balance);
|
||||
|
||||
await stockRepo.AddMovementAsync(new StockMovement
|
||||
{
|
||||
FK_ItemId = line.FK_ItemId,
|
||||
FromLocationId = warehouseId,
|
||||
FromLocationType = LocationType.Warehouse,
|
||||
ToLocationId = StockService.ExternalLocationId,
|
||||
ToLocationType = LocationType.External,
|
||||
Quantity = line.Quantity,
|
||||
Type = MovementType.PurchaseReturn,
|
||||
ReasonCode = request.Reason,
|
||||
ReferenceId = purchaseReturn.Id,
|
||||
CreatedBy = createdByUserId
|
||||
});
|
||||
await mover.MoveAsync(line.FK_ItemId, itemName,
|
||||
warehouseId, LocationType.Warehouse,
|
||||
StockService.ExternalLocationId, LocationType.External,
|
||||
line.Quantity, MovementType.PurchaseReturn, purchaseReturn.Id, createdByUserId, request.Reason);
|
||||
}
|
||||
|
||||
await uow.CommitAsync(ct);
|
||||
|
||||
@@ -1,39 +1,28 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Region;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/regions")]
|
||||
public class RegionController(
|
||||
RegionService service,
|
||||
IScopeAccessService scopeAccess,
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
public class RegionController(RegionService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
// Suggested code for the Add Region form; the user may override it.
|
||||
[HttpGet("next-code")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetNextCode() =>
|
||||
Ok(await service.GetNextCodeAsync());
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasRegionScopeAsync(userId.Value, id))
|
||||
return StatusCode(403);
|
||||
var result = await service.GetByIdAsync(id);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> Create(CreateRegionRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.CreateAsync(request, ct);
|
||||
@@ -41,7 +30,6 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateRegionRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateAsync(id, request, ct);
|
||||
@@ -49,7 +37,6 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteAsync(id, ct);
|
||||
@@ -57,7 +44,6 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/manager")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetManager(Guid id)
|
||||
{
|
||||
var result = await service.GetManagerAsync(id);
|
||||
@@ -65,7 +51,6 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/manager")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> SetManager(Guid id, SetRegionManagerRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -80,15 +65,14 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}/manager")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> RemoveManager(Guid id, CancellationToken ct)
|
||||
{
|
||||
var removed = await service.RemoveManagerAsync(id, ct);
|
||||
return removed ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
//targets/budgets/agencies/tax-rule.
|
||||
[HttpPut("{id:guid}/manage")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> Manage(Guid id, ManageRegionRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.ManageAsync(id, request, ct);
|
||||
@@ -96,7 +80,6 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/hierarchy")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetHierarchy(Guid id)
|
||||
{
|
||||
var result = await service.GetHierarchyAsync(id);
|
||||
@@ -104,20 +87,18 @@ public class RegionController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/dashboard")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetDashboard(Guid id, [FromQuery] string period)
|
||||
{
|
||||
var result = await service.GetDashboardAsync(id, period);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
// Flat CRUD-list view over targets/budgets/tax-rules/agency-maps across all regions.
|
||||
[HttpGet("manage-entries")]
|
||||
[Authorize("region.view")]
|
||||
public async Task<IActionResult> GetManageEntries() =>
|
||||
Ok(await service.GetManageEntriesAsync());
|
||||
|
||||
[HttpDelete("manage-entries/{entryType}/{id:guid}")]
|
||||
[Authorize("region.manage")]
|
||||
public async Task<IActionResult> DeleteManageEntry(RegionManageEntryType entryType, Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteManageEntryAsync(entryType, id, ct);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Returns;
|
||||
@@ -8,12 +7,10 @@ namespace Distribution.Features.Returns;
|
||||
public class ReturnController(ReturnService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/returns")]
|
||||
[Authorize("return.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
[HttpGet("api/returns/{id:guid}")]
|
||||
[Authorize("return.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -21,7 +18,6 @@ public class ReturnController(ReturnService service, ICurrentUserService current
|
||||
}
|
||||
|
||||
[HttpPatch("api/returns/{id:guid}/reasons")]
|
||||
[Authorize("return.manage")]
|
||||
public async Task<IActionResult> UpdateReasons(Guid id, UpdateSaleReturnReasonsRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -33,12 +29,10 @@ public class ReturnController(ReturnService service, ICurrentUserService current
|
||||
}
|
||||
|
||||
[HttpGet("api/shop-pos/{id:guid}/returns")]
|
||||
[Authorize("return.view")]
|
||||
public async Task<IActionResult> GetByShopPO(Guid id) =>
|
||||
Ok(await service.GetByShopPOIdAsync(id));
|
||||
|
||||
[HttpPost("api/shop-pos/{id:guid}/returns")]
|
||||
[Authorize("return.manage")]
|
||||
public async Task<IActionResult> Create(Guid id, CreateSaleReturnRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.CreatedByUserId;
|
||||
@@ -48,7 +42,7 @@ public class ReturnController(ReturnService service, ICurrentUserService current
|
||||
var result = await service.CreateAsync(id, request, userId.Value, ct);
|
||||
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
||||
}
|
||||
catch (NotImplementedException ex) { return StatusCode(501, new { error = ex.Message }); }
|
||||
|
||||
catch (InvalidOperationException ex) { return Conflict(new { error = ex.Message }); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Distribution.Features.Category;
|
||||
using Distribution.Features.Item;
|
||||
using Distribution.Features.ShopPO;
|
||||
using Distribution.Features.Stock;
|
||||
@@ -10,7 +11,8 @@ public class ReturnService(
|
||||
IReturnRepository repo,
|
||||
IShopPORepository shopPORepo,
|
||||
IItemRepository itemRepo,
|
||||
IStockRepository stockRepo,
|
||||
ICategoryRepository categoryRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
private static SaleReturnItemResponse MapItem(SaleReturnItem i) =>
|
||||
@@ -57,6 +59,72 @@ public class ReturnService(
|
||||
public async Task<List<SaleReturnResponse>> GetByShopPOIdAsync(Guid shopPOId) =>
|
||||
(await repo.GetByShopPOIdAsync(shopPOId)).Select(Map).ToList();
|
||||
|
||||
public Task<SaleReturnResponse> CreateAsync(Guid shopPOId, CreateSaleReturnRequest request, Guid createdByUserId, CancellationToken ct = default) =>
|
||||
throw new NotImplementedException("Return flow is being redesigned — not yet implemented.");
|
||||
/// <summary>
|
||||
/// Stock-only: records the return and puts the goods back on the vehicle that delivered them (restoring the
|
||||
/// batches/serials that were sold). Credit/exchange money handling is not applied here, so TotalCreditAmount stays 0.
|
||||
/// </summary>
|
||||
public async Task<SaleReturnResponse> CreateAsync(Guid shopPOId, CreateSaleReturnRequest request, Guid createdByUserId, CancellationToken ct = default)
|
||||
{
|
||||
var shopPO = await shopPORepo.GetByIdAsync(shopPOId);
|
||||
if (shopPO is null || !shopPO.IsActive)
|
||||
throw new InvalidOperationException("Order not found.");
|
||||
|
||||
if (request.Items is null || request.Items.Count == 0)
|
||||
throw new InvalidOperationException("A return must have at least one line item.");
|
||||
|
||||
if (request.Items.GroupBy(i => i.ItemId).Any(g => g.Count() > 1))
|
||||
throw new InvalidOperationException("Each item can appear only once on a return.");
|
||||
|
||||
var saleReturn = new SaleReturn
|
||||
{
|
||||
FK_ShopPOId = shopPOId,
|
||||
Mode = request.Mode,
|
||||
TotalCreditAmount = 0,
|
||||
CreatedByUserId = createdByUserId
|
||||
};
|
||||
|
||||
foreach (var line in request.Items)
|
||||
{
|
||||
if (line.Quantity <= 0)
|
||||
throw new InvalidOperationException("Return quantity must be greater than zero.");
|
||||
|
||||
var shopPOItem = shopPO.Items.FirstOrDefault(i => i.FK_ItemId == line.ItemId && i.IsActive)
|
||||
?? throw new InvalidOperationException($"Item {line.ItemId} is not on this order.");
|
||||
|
||||
var item = await itemRepo.GetByIdAsync(line.ItemId)
|
||||
?? throw new InvalidOperationException("Item not found.");
|
||||
|
||||
var category = await categoryRepo.GetByIdAsync(item.FK_CategoryId)
|
||||
?? throw new InvalidOperationException("Category not found.");
|
||||
|
||||
if (!category.AllowCustomerReturn)
|
||||
throw new InvalidOperationException($"Customer returns are not allowed for category '{category.Name}'.");
|
||||
|
||||
saleReturn.Items.Add(new SaleReturnItem
|
||||
{
|
||||
FK_ItemId = line.ItemId,
|
||||
Quantity = line.Quantity,
|
||||
ReasonCode = line.ReasonCode,
|
||||
UnitPrice = shopPOItem.UnitPrice
|
||||
});
|
||||
}
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await repo.AddAsync(saleReturn);
|
||||
|
||||
foreach (var line in saleReturn.Items)
|
||||
{
|
||||
var itemName = shopPO.Items.First(i => i.FK_ItemId == line.FK_ItemId).Item?.Name ?? line.FK_ItemId.ToString();
|
||||
await mover.ReturnToVehicleAsync(line.FK_ItemId, itemName, line.Quantity, shopPOId, createdByUserId, line.ReasonCode.ToString());
|
||||
}
|
||||
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
var saved = await repo.GetByIdAsync(saleReturn.Id);
|
||||
return Map(saved!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Distribution.Models;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Ride;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/rides")]
|
||||
public class RideController(RideService service) : ControllerBase
|
||||
public class RideController(RideService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll(
|
||||
@@ -54,7 +55,7 @@ public class RideController(RideService service) : ControllerBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await service.CloseAsync(id, request, ct);
|
||||
var result = await service.CloseAsync(id, request, currentUser.UserId ?? Guid.Empty, ct);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (KeyNotFoundException) { return NotFound(); }
|
||||
@@ -66,7 +67,7 @@ public class RideController(RideService service) : ControllerBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await service.CancelAsync(id, request, ct);
|
||||
var result = await service.CancelAsync(id, request, currentUser.UserId ?? Guid.Empty, ct);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (KeyNotFoundException) { return NotFound(); }
|
||||
|
||||
@@ -10,7 +10,7 @@ public class RideService(
|
||||
IRideRepository rideRepo,
|
||||
IDriverProfileRepository driverRepo,
|
||||
IDriverComplianceConfigRepository complianceRepo,
|
||||
IStockRepository stockRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
public async Task<PagedResponse<RideResponse>> GetAllAsync(RideStatus? status, Guid? driverProfileId, Guid? vehicleId, int page, int pageSize)
|
||||
@@ -76,7 +76,7 @@ public class RideService(
|
||||
return ToResponse(saved!);
|
||||
}
|
||||
|
||||
public async Task<RideResponse> CloseAsync(Guid rideId, CloseRideRequest request, CancellationToken ct = default)
|
||||
public async Task<RideResponse> CloseAsync(Guid rideId, CloseRideRequest request, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
var ride = await rideRepo.GetByIdAsync(rideId)
|
||||
?? throw new KeyNotFoundException("Ride not found");
|
||||
@@ -87,20 +87,24 @@ public class RideService(
|
||||
if (request.Meterend < ride.Meterstart)
|
||||
throw new InvalidOperationException($"Meter end ({request.Meterend}) cannot be less than meter start ({ride.Meterstart})");
|
||||
|
||||
await EnsureVehicleStockClearedAsync(ride.FK_VehicleId);
|
||||
|
||||
ride.Status = RideStatus.Closed;
|
||||
ride.ClosedAt = DateTime.Now;
|
||||
ride.Meterend = request.Meterend;
|
||||
|
||||
// Whatever wasn't delivered goes back to the warehouse it was loaded from.
|
||||
await uow.BeginAsync(ct);
|
||||
try { rideRepo.Update(ride); await uow.CommitAsync(ct); }
|
||||
try
|
||||
{
|
||||
await mover.UnloadVehicleAsync(ride.FK_VehicleId, ride.Id, userId, "RideClosed");
|
||||
rideRepo.Update(ride);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return ToResponse(ride);
|
||||
}
|
||||
|
||||
public async Task<RideResponse> CancelAsync(Guid rideId, CancelRideRequest request, CancellationToken ct = default)
|
||||
public async Task<RideResponse> CancelAsync(Guid rideId, CancelRideRequest request, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
var ride = await rideRepo.GetByIdAsync(rideId)
|
||||
?? throw new KeyNotFoundException("Ride not found");
|
||||
@@ -113,7 +117,12 @@ public class RideService(
|
||||
ride.CancelReason = request.Reason;
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try { rideRepo.Update(ride); await uow.CommitAsync(ct); }
|
||||
try
|
||||
{
|
||||
await mover.UnloadVehicleAsync(ride.FK_VehicleId, ride.Id, userId, "RideCancelled");
|
||||
rideRepo.Update(ride);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return ToResponse(ride);
|
||||
@@ -139,13 +148,6 @@ public class RideService(
|
||||
throw new InvalidOperationException("Driver medical clearance has expired");
|
||||
}
|
||||
|
||||
private async Task EnsureVehicleStockClearedAsync(Guid vehicleId)
|
||||
{
|
||||
var balances = await stockRepo.GetBalancesByLocationAsync(vehicleId, LocationType.Vehicle);
|
||||
if (balances.Any(b => b.Quantity > 0))
|
||||
throw new InvalidOperationException("All vehicle stock must be returned before this ride can be completed");
|
||||
}
|
||||
|
||||
private static RideResponse ToResponse(DeliveryRun r) =>
|
||||
new(r.Id, r.Status,
|
||||
r.FK_VehicleId, r.Vehicle?.NumberPlate ?? string.Empty,
|
||||
|
||||
@@ -5,8 +5,4 @@ public interface IRoleRepository
|
||||
Task<Models.Role?> GetByIdAsync(Guid id);
|
||||
Task<List<Models.Role>> GetAllAsync();
|
||||
Task<List<Models.RolePermission>> GetPermissionsAsync(Guid roleId);
|
||||
Task AddAsync(Models.Role role);
|
||||
void Update(Models.Role role);
|
||||
void Remove(Models.Role role);
|
||||
Task ReplacePermissionsAsync(Guid roleId, List<Guid> permissionIds);
|
||||
}
|
||||
|
||||
@@ -23,32 +23,4 @@ public class RoleController(RoleService service) : ControllerBase
|
||||
var result = await service.GetPermissionsAsync(id);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateRoleRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.CreateAsync(request, ct);
|
||||
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateRoleRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateAsync(id, request, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/permissions")]
|
||||
public async Task<IActionResult> AssignPermissions(Guid id, AssignRolePermissionsRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.AssignPermissionsAsync(id, request, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
public async Task<IActionResult> Deactivate(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deactivated = await service.DeactivateAsync(id, ct);
|
||||
return deactivated ? NoContent() : NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
namespace Distribution.Features.Role;
|
||||
|
||||
public record RoleResponse(Guid Id, string Name, int Level, bool IsActive, DateTime CreatedAt);
|
||||
|
||||
public record RolePermissionResponse(Guid PermissionId, string Code, string Description);
|
||||
public record CreateRoleRequest(string Name, int Level);
|
||||
public record UpdateRoleRequest(string Name, int Level);
|
||||
public record AssignRolePermissionsRequest(List<Guid> PermissionIds);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.Role;
|
||||
@@ -17,29 +16,4 @@ public class RoleRepository(AppDBContext context) : IRoleRepository
|
||||
.Include(rp => rp.Permission)
|
||||
.Where(rp => rp.FK_RoleId == roleId && rp.IsActive)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task AddAsync(Models.Role role) =>
|
||||
await context.Roles.AddAsync(role);
|
||||
|
||||
public void Update(Models.Role role) =>
|
||||
context.Roles.Update(role);
|
||||
|
||||
public void Remove(Models.Role role)
|
||||
{
|
||||
role.IsActive = false;
|
||||
context.Roles.Update(role);
|
||||
}
|
||||
|
||||
public async Task ReplacePermissionsAsync(Guid roleId, List<Guid> permissionIds)
|
||||
{
|
||||
var existing = await context.RolePermissions
|
||||
.Where(rp => rp.FK_RoleId == roleId)
|
||||
.ToListAsync();
|
||||
context.RolePermissions.RemoveRange(existing);
|
||||
context.RolePermissions.AddRange(permissionIds.Select(pid => new RolePermission
|
||||
{
|
||||
FK_RoleId = roleId,
|
||||
FK_PermissionId = pid
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
using Distribution.Infra.UoW;
|
||||
|
||||
namespace Distribution.Features.Role;
|
||||
|
||||
public class RoleService(IRoleRepository repo, IUnitOfWork uow)
|
||||
public class RoleService(IRoleRepository repo)
|
||||
{
|
||||
private static RoleResponse ToResponse(Models.Role r) =>
|
||||
new(r.Id, r.Name, r.Level, r.IsActive, r.CreatedAt);
|
||||
|
||||
public async Task<List<RoleResponse>> GetAllAsync() =>
|
||||
(await repo.GetAllAsync())
|
||||
.Where(r => r.IsActive)
|
||||
.Select(ToResponse)
|
||||
.Select(r => new RoleResponse(r.Id, r.Name, r.Level, r.IsActive, r.CreatedAt))
|
||||
.ToList();
|
||||
|
||||
public async Task<RoleResponse?> GetByIdAsync(Guid id)
|
||||
{
|
||||
var role = await repo.GetByIdAsync(id);
|
||||
if (role is null || !role.IsActive) return null;
|
||||
return ToResponse(role);
|
||||
return new RoleResponse(role.Id, role.Name, role.Level, role.IsActive, role.CreatedAt);
|
||||
}
|
||||
|
||||
public async Task<List<RolePermissionResponse>?> GetPermissionsAsync(Guid roleId)
|
||||
@@ -28,77 +23,4 @@ public class RoleService(IRoleRepository repo, IUnitOfWork uow)
|
||||
.Select(rp => new RolePermissionResponse(rp.FK_PermissionId, rp.Permission.Code, rp.Permission.Description))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task<RoleResponse> CreateAsync(CreateRoleRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var role = new Models.Role { Name = request.Name, Level = request.Level };
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await repo.AddAsync(role);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await uow.RollbackAsync(ct);
|
||||
throw;
|
||||
}
|
||||
return ToResponse(role);
|
||||
}
|
||||
|
||||
public async Task<RoleResponse?> UpdateAsync(Guid id, UpdateRoleRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var role = await repo.GetByIdAsync(id);
|
||||
if (role is null || !role.IsActive) return null;
|
||||
role.Name = request.Name;
|
||||
role.Level = request.Level;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
repo.Update(role);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await uow.RollbackAsync(ct);
|
||||
throw;
|
||||
}
|
||||
return ToResponse(role);
|
||||
}
|
||||
|
||||
public async Task<bool> DeactivateAsync(Guid id, CancellationToken ct = default)
|
||||
{
|
||||
var role = await repo.GetByIdAsync(id);
|
||||
if (role is null || !role.IsActive) return false;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
repo.Remove(role);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await uow.RollbackAsync(ct);
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<List<RolePermissionResponse>?> AssignPermissionsAsync(Guid id, AssignRolePermissionsRequest request, CancellationToken ct = default)
|
||||
{
|
||||
var role = await repo.GetByIdAsync(id);
|
||||
if (role is null || !role.IsActive) return null;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await repo.ReplacePermissionsAsync(id, request.PermissionIds);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await uow.RollbackAsync(ct);
|
||||
throw;
|
||||
}
|
||||
return await GetPermissionsAsync(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,23 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Route;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/routes")]
|
||||
public class RouteController(
|
||||
RouteService service,
|
||||
IScopeAccessService scopeAccess,
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
public class RouteController(RouteService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("route.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("route.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasRouteScopeAsync(userId.Value, id))
|
||||
return StatusCode(403);
|
||||
var result = await service.GetByIdAsync(id);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> Create(CreateRouteRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.CreateAsync(request, ct);
|
||||
@@ -36,7 +25,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateRouteRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateAsync(id, request, ct);
|
||||
@@ -44,7 +32,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/region")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> AssignToRegion(Guid id, AssignRouteToRegionRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.AssignToRegionAsync(id, request, ct);
|
||||
@@ -52,7 +39,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteAsync(id, ct);
|
||||
@@ -60,7 +46,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/stores")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> AssignStores(Guid id, AssignStoresToRouteRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.AssignStoresToRouteAsync(id, request, ct);
|
||||
@@ -68,7 +53,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/owner")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> AssignOwner(Guid id, AssignRouteOwnerRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.AssignOwnerAsync(id, request, ct);
|
||||
@@ -76,12 +60,10 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/optimize")]
|
||||
[Authorize("route.manage")]
|
||||
public IActionResult OptimizeSequence(Guid id) =>
|
||||
StatusCode(StatusCodes.Status501NotImplemented);
|
||||
|
||||
[HttpPost("{id:guid}/visits/check-in")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> CheckIn(Guid id, RecordCheckInRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -93,7 +75,6 @@ public class RouteController(
|
||||
}
|
||||
|
||||
[HttpPost("{id:guid}/visits/check-out")]
|
||||
[Authorize("route.manage")]
|
||||
public async Task<IActionResult> CheckOut(Guid id, RecordCheckOutRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.RecordCheckOutAsync(id, request, ct);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Scheme;
|
||||
|
||||
@@ -8,12 +7,10 @@ namespace Distribution.Features.Scheme;
|
||||
public class SchemeController(SchemeService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("scheme.view")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] Guid? regionId) =>
|
||||
Ok(await service.GetAllAsync(regionId));
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("scheme.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -21,7 +18,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> Create(CreateSchemeRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -36,7 +32,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateSchemeRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -51,7 +46,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteAsync(id, ct);
|
||||
@@ -59,7 +53,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/free-goods-rule")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> SetFreeGoodsRule(Guid id, SetFreeGoodsRuleRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -74,7 +67,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}/free-goods-rule")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> ClearFreeGoodsRule(Guid id, CancellationToken ct)
|
||||
{
|
||||
var result = await service.ClearFreeGoodsRuleAsync(id, ct);
|
||||
@@ -82,7 +74,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/bundle-components/{itemId:guid}")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> UpsertBundleComponent(Guid id, Guid itemId, UpsertBundleComponentRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -97,7 +88,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}/bundle-components/{itemId:guid}")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> RemoveBundleComponent(Guid id, Guid itemId, CancellationToken ct)
|
||||
{
|
||||
var result = await service.RemoveBundleComponentAsync(id, itemId, ct);
|
||||
@@ -105,7 +95,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("eligible")]
|
||||
[Authorize("scheme.view")]
|
||||
public async Task<IActionResult> GetEligible([FromQuery] Guid storeId, [FromQuery] Guid orderId)
|
||||
{
|
||||
var result = await service.EvaluateEligibilityAsync(storeId, orderId);
|
||||
@@ -113,7 +102,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/spend")]
|
||||
[Authorize("scheme.view")]
|
||||
public async Task<IActionResult> GetSpend(Guid id)
|
||||
{
|
||||
var result = await service.GetSpendAsync(id);
|
||||
@@ -121,7 +109,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/roi")]
|
||||
[Authorize("scheme.view")]
|
||||
public async Task<IActionResult> GetROI(Guid id)
|
||||
{
|
||||
var result = await service.GetROIAsync(id);
|
||||
@@ -134,7 +121,6 @@ public class SchemeController(SchemeService service) : ControllerBase
|
||||
public class SchemeOrderController(SchemeService service) : ControllerBase
|
||||
{
|
||||
[HttpPost("{id:guid}/apply-scheme")]
|
||||
[Authorize("scheme.manage")]
|
||||
public async Task<IActionResult> ApplyScheme(Guid id, ApplySchemeRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -7,6 +7,8 @@ public interface IStockRepository
|
||||
// Balance
|
||||
Task<StockBalance?> GetBalanceAsync(Guid itemId, Guid locationId);
|
||||
Task<StockBalance?> GetBalanceAsync(Guid itemId, Guid locationId, Guid? itemBatchId, Guid? itemSerialNumberId);
|
||||
/// <summary>Positive balances for the item at the location in pick order: batches by earliest expiry, serials oldest first, untracked last.</summary>
|
||||
Task<List<StockBalance>> GetAllocatableBalancesAsync(Guid itemId, Guid locationId);
|
||||
Task<List<StockBalance>> GetBalancesByLocationAsync(Guid locationId, LocationType locationType);
|
||||
Task<List<StockBalance>> GetBalancesAsync(Guid? locationId, LocationType? locationType, Guid? itemId, int page, int pageSize);
|
||||
Task<int> GetBalancesCountAsync(Guid? locationId, LocationType? locationType, Guid? itemId);
|
||||
@@ -19,14 +21,21 @@ public interface IStockRepository
|
||||
Task AddMovementAsync(StockMovement movement);
|
||||
Task<StockMovement?> GetMovementByIdAsync(Guid id);
|
||||
void UpdateMovement(StockMovement movement);
|
||||
Task<List<StockMovement>> GetMovementsAsync(Guid? locationId, Guid? itemId, MovementType? type, DateTime? from, DateTime? to, int page, int pageSize);
|
||||
Task<int> GetMovementsCountAsync(Guid? locationId, Guid? itemId, MovementType? type, DateTime? from, DateTime? to);
|
||||
Task<List<StockMovement>> GetMovementsAsync(MovementFilter filter, int page, int pageSize);
|
||||
Task<int> GetMovementsCountAsync(MovementFilter filter);
|
||||
/// <summary>Opening balance, quantity in/out within [from, toExclusive), closing balance, and the live balance to reconcile against.</summary>
|
||||
Task<MovementSummary> GetMovementSummaryAsync(Guid itemId, Guid locationId, DateTime from, DateTime toExclusive);
|
||||
|
||||
Task<List<StockMovement>> GetMovementsByReferenceAsync(Guid referenceId, Guid itemId, MovementType type);
|
||||
/// <summary>The warehouse the item most recently arrived at <paramref name="vehicleId"/> from, or null if it never did.</summary>
|
||||
Task<Guid?> GetLastWarehouseSourceAsync(Guid vehicleId, Guid itemId);
|
||||
|
||||
// Batches — a null batchNumber always creates a fresh expiry-only lot (no dedup possible on null).
|
||||
Task<ItemBatch?> FindBatchAsync(Guid itemId, string batchNumber);
|
||||
Task AddItemBatchAsync(ItemBatch batch);
|
||||
|
||||
// Serial numbers
|
||||
Task<ItemSerialNumber?> GetSerialAsync(Guid serialId);
|
||||
Task<bool> SerialNumberExistsAsync(Guid itemId, string serialNumber);
|
||||
/// <summary>One past the highest numeric suffix among the item's existing serials that start with <paramref name="prefix"/> (1 if none).</summary>
|
||||
Task<int> GetNextSerialSequenceAsync(Guid itemId, string prefix);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Stock;
|
||||
@@ -9,10 +8,9 @@ namespace Distribution.Features.Stock;
|
||||
[Route("api/stock")]
|
||||
public class StockController(StockService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
// ── Query ──────────────────────────────────────────────────────────────────
|
||||
// ── Query ──────────────────────────────────────────────────────────────
|
||||
|
||||
[HttpGet("balances")]
|
||||
[Authorize("stock.view")]
|
||||
public async Task<IActionResult> GetBalances(
|
||||
[FromQuery] Guid? locationId,
|
||||
[FromQuery] LocationType? locationType,
|
||||
@@ -25,7 +23,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpGet("low-stock")]
|
||||
[Authorize("stock.view")]
|
||||
public async Task<IActionResult> GetLowStock([FromQuery] Guid? locationId)
|
||||
{
|
||||
var result = await service.GetLowStockAsync(locationId);
|
||||
@@ -33,7 +30,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpGet("balances/{itemId}/total")]
|
||||
[Authorize("stock.view")]
|
||||
public async Task<IActionResult> GetItemTotal(Guid itemId)
|
||||
{
|
||||
var result = await service.GetItemTotalAsync(itemId);
|
||||
@@ -43,7 +39,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
|
||||
/// <summary>Next free number for auto-generated serials (e.g. after ...-0005 the answer is 6).</summary>
|
||||
[HttpGet("serials/next-sequence")]
|
||||
[Authorize("stock.view")]
|
||||
public async Task<IActionResult> GetNextSerialSequence([FromQuery] Guid itemId, [FromQuery] string prefix = "")
|
||||
{
|
||||
var next = await service.GetNextSerialSequenceAsync(itemId, prefix);
|
||||
@@ -51,24 +46,40 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpGet("movements")]
|
||||
//[Authorize("stock.view")]
|
||||
public async Task<IActionResult> GetMovements(
|
||||
[FromQuery] Guid? locationId,
|
||||
[FromQuery] Guid? itemId,
|
||||
[FromQuery] MovementType? type,
|
||||
[FromQuery] DateTime? from,
|
||||
[FromQuery] DateTime? to,
|
||||
[FromQuery] Guid? referenceId,
|
||||
[FromQuery] Guid? batchId,
|
||||
[FromQuery] Guid? serialId,
|
||||
[FromQuery] Guid? createdBy,
|
||||
[FromQuery] string? reasonCode,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20)
|
||||
{
|
||||
var result = await service.GetMovementsAsync(locationId, itemId, type, from, to, page, pageSize);
|
||||
var filter = new MovementFilter(locationId, itemId, type, from, to, referenceId, batchId, serialId, createdBy, reasonCode);
|
||||
var result = await service.GetMovementsAsync(filter, page, pageSize);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// ── Write ──────────────────────────────────────────────────────────────────
|
||||
/// <summary>Opening / in / out / closing quantity for one item at one location over a date range.</summary>
|
||||
[HttpGet("movements/summary")]
|
||||
public async Task<IActionResult> GetMovementSummary(
|
||||
[FromQuery] Guid itemId,
|
||||
[FromQuery] Guid locationId,
|
||||
[FromQuery] DateTime from,
|
||||
[FromQuery] DateTime to)
|
||||
{
|
||||
var result = await service.GetMovementSummaryAsync(itemId, locationId, from, to);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// ── Write ──────────────────────────────────────────────────────────────
|
||||
|
||||
[HttpPost("transfer")]
|
||||
[Authorize("stock.manage")]
|
||||
public async Task<IActionResult> Transfer(TransferRequest request, CancellationToken ct)
|
||||
{
|
||||
if (currentUser.UserId is null) return Unauthorized();
|
||||
@@ -81,7 +92,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPost("damage")]
|
||||
[Authorize("stock.manage")]
|
||||
public async Task<IActionResult> RecordDamage(DamageRequest request, CancellationToken ct)
|
||||
{
|
||||
if (currentUser.UserId is null) return Unauthorized();
|
||||
@@ -94,7 +104,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPost("customer-return")]
|
||||
[Authorize("stock.manage")]
|
||||
public async Task<IActionResult> RecordCustomerReturn(CustomerReturnRequest request, CancellationToken ct)
|
||||
{
|
||||
if (currentUser.UserId is null) return Unauthorized();
|
||||
@@ -107,7 +116,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPost("adjustment")]
|
||||
[Authorize("stock.manage")]
|
||||
public async Task<IActionResult> Adjust(AdjustmentRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
@@ -123,7 +131,6 @@ public class StockController(StockService service, ICurrentUserService currentUs
|
||||
}
|
||||
|
||||
[HttpPatch("movements/{id}/reason")]
|
||||
[Authorize("stock.manage")]
|
||||
public async Task<IActionResult> UpdateMovementReason(Guid id, UpdateMovementReasonRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -45,7 +45,12 @@ public record StockMovementResponse(
|
||||
DateTime CreatedAt,
|
||||
Guid CreatedBy,
|
||||
string? FromLocationName,
|
||||
string? ToLocationName);
|
||||
string? ToLocationName,
|
||||
Guid? BatchId = null,
|
||||
string? BatchNumber = null,
|
||||
DateTime? BatchExpiryDate = null,
|
||||
Guid? SerialId = null,
|
||||
string? SerialNumber = null);
|
||||
|
||||
// Write requests
|
||||
public record TransferRequest(
|
||||
@@ -82,3 +87,23 @@ public record AdjustmentRequest(
|
||||
// Movements are an immutable ledger — quantity, locations, and type can never change once recorded
|
||||
// (the running stock balance is the sum of all movements). Only the free-text reason/note is editable.
|
||||
public record UpdateMovementReasonRequest(string ReasonCode);
|
||||
|
||||
// Movement report filters
|
||||
public record MovementFilter(
|
||||
Guid? LocationId = null,
|
||||
Guid? ItemId = null,
|
||||
MovementType? Type = null,
|
||||
DateTime? From = null,
|
||||
DateTime? To = null,
|
||||
Guid? ReferenceId = null,
|
||||
Guid? BatchId = null,
|
||||
Guid? SerialId = null,
|
||||
Guid? CreatedBy = null,
|
||||
string? ReasonCode = null);
|
||||
|
||||
public record MovementSummary(
|
||||
decimal OpeningQuantity,
|
||||
decimal QuantityIn,
|
||||
decimal QuantityOut,
|
||||
decimal ClosingQuantity,
|
||||
decimal CurrentBalance);
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
using Distribution.Features.SysConfig;
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Stock;
|
||||
|
||||
/// <summary>
|
||||
/// Applies a stock movement end to end: picks which batch/serial balances to take from (FEFO / FIFO),
|
||||
/// updates the source and destination balances, keeps serial status/location in step, and writes one
|
||||
/// StockMovement per slice so the ledger always carries the batch/serial that actually moved.
|
||||
/// Tracks changes only — the calling service owns the unit of work.
|
||||
/// </summary>
|
||||
public class StockMover(IStockRepository repo, SysConfigService sysConfig)
|
||||
{
|
||||
private static readonly Guid External = StockService.ExternalLocationId;
|
||||
|
||||
private readonly record struct StockKey(Guid LocationId, Guid? BatchId, Guid? SerialId);
|
||||
|
||||
public async Task<List<StockMovement>> MoveAsync(
|
||||
Guid itemId, string itemName,
|
||||
Guid fromId, LocationType fromType,
|
||||
Guid toId, LocationType toType,
|
||||
decimal quantity, MovementType type,
|
||||
Guid? referenceId, Guid userId, string? reasonCode = null)
|
||||
{
|
||||
if (quantity <= 0)
|
||||
throw new InvalidOperationException("Quantity must be greater than zero.");
|
||||
|
||||
var balances = await repo.GetAllocatableBalancesAsync(itemId, fromId);
|
||||
var available = balances.Sum(b => b.Quantity);
|
||||
if (available < quantity)
|
||||
throw new InvalidOperationException(
|
||||
$"Insufficient stock for '{itemName}': available {available}, required {quantity}");
|
||||
|
||||
var created = new List<StockMovement>();
|
||||
var remaining = quantity;
|
||||
foreach (var balance in balances)
|
||||
{
|
||||
if (remaining <= 0) break;
|
||||
var take = Math.Min(balance.Quantity, remaining);
|
||||
|
||||
balance.Quantity -= take;
|
||||
balance.UpdatedAt = DateTime.Now;
|
||||
repo.UpdateBalance(balance);
|
||||
|
||||
if (toType != LocationType.External)
|
||||
await CreditAsync(itemId, toId, toType, balance.FK_ItemBatchId, balance.FK_ItemSerialNumberId, take);
|
||||
|
||||
if (balance.ItemSerialNumber is not null)
|
||||
await ApplySerialAsync(balance.ItemSerialNumber, balance.Item, toId, toType, type);
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = itemId,
|
||||
FromLocationId = fromId,
|
||||
FromLocationType = fromType,
|
||||
ToLocationId = toId,
|
||||
ToLocationType = toType,
|
||||
FK_ItemBatchId = balance.FK_ItemBatchId,
|
||||
FK_ItemSerialNumberId = balance.FK_ItemSerialNumberId,
|
||||
Quantity = take,
|
||||
Type = type,
|
||||
ReasonCode = reasonCode,
|
||||
ReferenceId = referenceId,
|
||||
CreatedBy = userId
|
||||
};
|
||||
await repo.AddMovementAsync(movement);
|
||||
created.Add(movement);
|
||||
|
||||
remaining -= take;
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts returned goods back on the vehicle that delivered them, restoring the same batches/serials that
|
||||
/// were sold on that ShopPO. Quantity is capped at what was delivered and not yet returned.
|
||||
/// </summary>
|
||||
public async Task<List<StockMovement>> ReturnToVehicleAsync(
|
||||
Guid itemId, string itemName, decimal quantity, Guid shopPoId, Guid userId, string? reasonCode = null)
|
||||
{
|
||||
if (quantity <= 0)
|
||||
throw new InvalidOperationException("Quantity must be greater than zero.");
|
||||
|
||||
var sold = await repo.GetMovementsByReferenceAsync(shopPoId, itemId, MovementType.Sale);
|
||||
if (sold.Count == 0)
|
||||
throw new InvalidOperationException($"'{itemName}' was not delivered on this order, so it cannot be returned.");
|
||||
|
||||
var returned = await repo.GetMovementsByReferenceAsync(shopPoId, itemId, MovementType.CustomerReturn);
|
||||
|
||||
var outstanding = new Dictionary<StockKey, decimal>();
|
||||
foreach (var m in sold)
|
||||
{
|
||||
var key = new StockKey(m.FromLocationId!.Value, m.FK_ItemBatchId, m.FK_ItemSerialNumberId);
|
||||
outstanding[key] = outstanding.GetValueOrDefault(key) + m.Quantity;
|
||||
}
|
||||
foreach (var m in returned)
|
||||
{
|
||||
var key = new StockKey(m.ToLocationId!.Value, m.FK_ItemBatchId, m.FK_ItemSerialNumberId);
|
||||
outstanding[key] = outstanding.GetValueOrDefault(key) - m.Quantity;
|
||||
}
|
||||
|
||||
var returnable = outstanding.Where(kv => kv.Value > 0).Sum(kv => kv.Value);
|
||||
if (quantity > returnable)
|
||||
throw new InvalidOperationException(
|
||||
$"Return quantity for '{itemName}' ({quantity}) exceeds the delivered-but-not-yet-returned quantity ({returnable}).");
|
||||
|
||||
var created = new List<StockMovement>();
|
||||
var remaining = quantity;
|
||||
foreach (var (key, qty) in outstanding.Where(kv => kv.Value > 0))
|
||||
{
|
||||
if (remaining <= 0) break;
|
||||
var take = Math.Min(qty, remaining);
|
||||
|
||||
await CreditAsync(itemId, key.LocationId, LocationType.Vehicle, key.BatchId, key.SerialId, take);
|
||||
|
||||
if (key.SerialId is Guid serialId)
|
||||
{
|
||||
var serial = await repo.GetSerialAsync(serialId);
|
||||
if (serial is not null)
|
||||
await ApplySerialAsync(serial, null, key.LocationId, LocationType.Vehicle, MovementType.CustomerReturn);
|
||||
}
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = itemId,
|
||||
FromLocationId = External,
|
||||
FromLocationType = LocationType.External,
|
||||
ToLocationId = key.LocationId,
|
||||
ToLocationType = LocationType.Vehicle,
|
||||
FK_ItemBatchId = key.BatchId,
|
||||
FK_ItemSerialNumberId = key.SerialId,
|
||||
Quantity = take,
|
||||
Type = MovementType.CustomerReturn,
|
||||
ReasonCode = reasonCode,
|
||||
ReferenceId = shopPoId,
|
||||
CreatedBy = userId
|
||||
};
|
||||
await repo.AddMovementAsync(movement);
|
||||
created.Add(movement);
|
||||
|
||||
remaining -= take;
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends everything still on the vehicle back to the warehouse it was loaded from.
|
||||
/// </summary>
|
||||
public async Task UnloadVehicleAsync(Guid vehicleId, Guid referenceId, Guid userId, string reasonCode)
|
||||
{
|
||||
var onVehicle = (await repo.GetBalancesByLocationAsync(vehicleId, LocationType.Vehicle))
|
||||
.Where(b => b.Quantity > 0)
|
||||
.GroupBy(b => b.FK_ItemId);
|
||||
|
||||
foreach (var group in onVehicle)
|
||||
{
|
||||
var item = group.First().Item;
|
||||
var warehouseId = await repo.GetLastWarehouseSourceAsync(vehicleId, group.Key)
|
||||
?? throw new InvalidOperationException(
|
||||
$"Cannot unload '{item.Name}': no source warehouse found for the stock on this vehicle.");
|
||||
|
||||
await MoveAsync(group.Key, item.Name, vehicleId, LocationType.Vehicle,
|
||||
warehouseId, LocationType.Warehouse, group.Sum(b => b.Quantity),
|
||||
MovementType.Transfer, referenceId, userId, reasonCode);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreditAsync(Guid itemId, Guid locationId, LocationType locationType,
|
||||
Guid? batchId, Guid? serialId, decimal quantity)
|
||||
{
|
||||
var balance = await repo.GetBalanceAsync(itemId, locationId, batchId, serialId);
|
||||
if (balance is null)
|
||||
{
|
||||
await repo.AddBalanceAsync(new StockBalance
|
||||
{
|
||||
FK_ItemId = itemId,
|
||||
LocationId = locationId,
|
||||
LocationType = locationType,
|
||||
FK_ItemBatchId = batchId,
|
||||
FK_ItemSerialNumberId = serialId,
|
||||
Quantity = quantity
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
balance.Quantity += quantity;
|
||||
balance.UpdatedAt = DateTime.Now;
|
||||
repo.UpdateBalance(balance);
|
||||
}
|
||||
|
||||
private async Task ApplySerialAsync(ItemSerialNumber serial, Models.Item? item, Guid toId, LocationType toType, MovementType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MovementType.Sale:
|
||||
serial.Status = SerialStatus.Sold;
|
||||
serial.CurrentLocationId = null;
|
||||
serial.CurrentLocationType = null;
|
||||
// Warranty clock starts at sale, not receipt.
|
||||
if (item is { HasWarranty: true } && await sysConfig.GetWarrantyTrackingEnabledAsync())
|
||||
{
|
||||
var days = serial.WarrantyPeriodDaysOverride ?? await sysConfig.GetDefaultWarrantyPeriodDaysAsync();
|
||||
serial.WarrantyExpiresAt = DateTime.Now.AddDays(days);
|
||||
}
|
||||
break;
|
||||
|
||||
case MovementType.Damage:
|
||||
serial.Status = SerialStatus.Damaged;
|
||||
serial.CurrentLocationId = null;
|
||||
serial.CurrentLocationType = null;
|
||||
break;
|
||||
|
||||
case MovementType.CustomerReturn:
|
||||
serial.Status = SerialStatus.Returned;
|
||||
serial.CurrentLocationId = toId;
|
||||
serial.CurrentLocationType = toType;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (toType == LocationType.External)
|
||||
{
|
||||
serial.CurrentLocationId = null;
|
||||
serial.CurrentLocationType = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == MovementType.Load) serial.Status = SerialStatus.InStock;
|
||||
serial.CurrentLocationId = toId;
|
||||
serial.CurrentLocationType = toType;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,39 @@ namespace Distribution.Features.Stock;
|
||||
public class StockRepository(AppDBContext db) : IStockRepository
|
||||
{
|
||||
public Task<StockBalance?> GetBalanceAsync(Guid itemId, Guid locationId) =>
|
||||
db.StockBalances
|
||||
.Include(b => b.Item)
|
||||
.FirstOrDefaultAsync(b => b.FK_ItemId == itemId && b.LocationId == locationId
|
||||
&& b.FK_ItemBatchId == null && b.FK_ItemSerialNumberId == null);
|
||||
GetBalanceAsync(itemId, locationId, null, null);
|
||||
|
||||
public Task<StockBalance?> GetBalanceAsync(Guid itemId, Guid locationId, Guid? itemBatchId, Guid? itemSerialNumberId) =>
|
||||
db.StockBalances
|
||||
// Looks at rows added earlier in the same unit of work first — they aren't in the database yet,
|
||||
// so a second movement for the same (item, location, batch, serial) would otherwise insert a duplicate.
|
||||
public async Task<StockBalance?> GetBalanceAsync(Guid itemId, Guid locationId, Guid? itemBatchId, Guid? itemSerialNumberId)
|
||||
{
|
||||
var pending = db.StockBalances.Local.FirstOrDefault(b => b.FK_ItemId == itemId && b.LocationId == locationId
|
||||
&& b.FK_ItemBatchId == itemBatchId && b.FK_ItemSerialNumberId == itemSerialNumberId);
|
||||
if (pending is not null) return pending;
|
||||
|
||||
return await db.StockBalances
|
||||
.Include(b => b.Item)
|
||||
.FirstOrDefaultAsync(b => b.FK_ItemId == itemId && b.LocationId == locationId
|
||||
&& b.FK_ItemBatchId == itemBatchId && b.FK_ItemSerialNumberId == itemSerialNumberId);
|
||||
}
|
||||
|
||||
public async Task<List<StockBalance>> GetAllocatableBalancesAsync(Guid itemId, Guid locationId)
|
||||
{
|
||||
var balances = await db.StockBalances
|
||||
.Include(b => b.Item)
|
||||
.Include(b => b.ItemBatch)
|
||||
.Include(b => b.ItemSerialNumber)
|
||||
.Where(b => b.FK_ItemId == itemId && b.LocationId == locationId && b.Quantity > 0)
|
||||
.ToListAsync();
|
||||
|
||||
// Tracked stock first: earliest expiry (FEFO), then oldest received serial (FIFO); untracked rows last.
|
||||
return balances
|
||||
.OrderBy(b => b.FK_ItemBatchId == null && b.FK_ItemSerialNumberId == null ? 1 : 0)
|
||||
.ThenBy(b => b.ItemBatch?.ExpiryDate ?? DateTime.MaxValue)
|
||||
.ThenBy(b => b.ItemSerialNumber?.ReceivedAt ?? DateTime.MaxValue)
|
||||
.ThenBy(b => b.UpdatedAt)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Task<List<StockBalance>> GetBalancesByLocationAsync(Guid locationId, LocationType locationType) =>
|
||||
db.StockBalances
|
||||
@@ -69,41 +92,88 @@ public class StockRepository(AppDBContext db) : IStockRepository
|
||||
await db.StockMovements.AddAsync(movement);
|
||||
|
||||
public Task<StockMovement?> GetMovementByIdAsync(Guid id) =>
|
||||
db.StockMovements.Include(m => m.Item).FirstOrDefaultAsync(m => m.Id == id);
|
||||
db.StockMovements.Include(m => m.Item).Include(m => m.ItemBatch).Include(m => m.ItemSerialNumber).FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
public void UpdateMovement(StockMovement movement) =>
|
||||
db.StockMovements.Update(movement);
|
||||
|
||||
public Task<List<StockMovement>> GetMovementsAsync(Guid? locationId, Guid? itemId, MovementType? type, DateTime? from, DateTime? to, int page, int pageSize)
|
||||
{
|
||||
var query = db.StockMovements.Include(m => m.Item).AsQueryable();
|
||||
if (locationId.HasValue)
|
||||
query = query.Where(m => m.FromLocationId == locationId.Value || m.ToLocationId == locationId.Value);
|
||||
if (itemId.HasValue) query = query.Where(m => m.FK_ItemId == itemId.Value);
|
||||
if (type.HasValue) query = query.Where(m => m.Type == type.Value);
|
||||
if (from.HasValue) query = query.Where(m => m.CreatedAt >= from.Value);
|
||||
if (to.HasValue) query = query.Where(m => m.CreatedAt <= to.Value);
|
||||
return query.OrderByDescending(m => m.CreatedAt).Skip((page - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
}
|
||||
|
||||
public Task<int> GetMovementsCountAsync(Guid? locationId, Guid? itemId, MovementType? type, DateTime? from, DateTime? to)
|
||||
private IQueryable<StockMovement> FilterMovements(MovementFilter f)
|
||||
{
|
||||
var query = db.StockMovements.AsQueryable();
|
||||
if (locationId.HasValue)
|
||||
query = query.Where(m => m.FromLocationId == locationId.Value || m.ToLocationId == locationId.Value);
|
||||
if (itemId.HasValue) query = query.Where(m => m.FK_ItemId == itemId.Value);
|
||||
if (type.HasValue) query = query.Where(m => m.Type == type.Value);
|
||||
if (from.HasValue) query = query.Where(m => m.CreatedAt >= from.Value);
|
||||
if (to.HasValue) query = query.Where(m => m.CreatedAt <= to.Value);
|
||||
return query.CountAsync();
|
||||
if (f.LocationId.HasValue)
|
||||
query = query.Where(m => m.FromLocationId == f.LocationId.Value || m.ToLocationId == f.LocationId.Value);
|
||||
if (f.ItemId.HasValue) query = query.Where(m => m.FK_ItemId == f.ItemId.Value);
|
||||
if (f.Type.HasValue) query = query.Where(m => m.Type == f.Type.Value);
|
||||
if (f.ReferenceId.HasValue) query = query.Where(m => m.ReferenceId == f.ReferenceId.Value);
|
||||
if (f.BatchId.HasValue) query = query.Where(m => m.FK_ItemBatchId == f.BatchId.Value);
|
||||
if (f.SerialId.HasValue) query = query.Where(m => m.FK_ItemSerialNumberId == f.SerialId.Value);
|
||||
if (f.CreatedBy.HasValue) query = query.Where(m => m.CreatedBy == f.CreatedBy.Value);
|
||||
if (!string.IsNullOrWhiteSpace(f.ReasonCode)) query = query.Where(m => m.ReasonCode == f.ReasonCode);
|
||||
if (f.From.HasValue) query = query.Where(m => m.CreatedAt >= f.From.Value);
|
||||
if (f.To.HasValue)
|
||||
{
|
||||
// A bare date (midnight) means "through the end of that day".
|
||||
var to = f.To.Value;
|
||||
var toExclusive = to.TimeOfDay == TimeSpan.Zero ? to.AddDays(1) : to;
|
||||
query = query.Where(m => m.CreatedAt < toExclusive);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
public Task<List<StockMovement>> GetMovementsAsync(MovementFilter filter, int page, int pageSize) =>
|
||||
FilterMovements(filter)
|
||||
.Include(m => m.Item)
|
||||
.Include(m => m.ItemBatch)
|
||||
.Include(m => m.ItemSerialNumber)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.Skip((page - 1) * pageSize).Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
public Task<int> GetMovementsCountAsync(MovementFilter filter) =>
|
||||
FilterMovements(filter).CountAsync();
|
||||
|
||||
public async Task<MovementSummary> GetMovementSummaryAsync(Guid itemId, Guid locationId, DateTime from, DateTime toExclusive)
|
||||
{
|
||||
var rows = db.StockMovements.AsNoTracking()
|
||||
.Where(m => m.FK_ItemId == itemId && (m.FromLocationId == locationId || m.ToLocationId == locationId));
|
||||
|
||||
var before = await rows.Where(m => m.CreatedAt < from)
|
||||
.GroupBy(_ => 1)
|
||||
.Select(g => g.Sum(m => m.ToLocationId == locationId ? m.Quantity : 0)
|
||||
- g.Sum(m => m.FromLocationId == locationId ? m.Quantity : 0))
|
||||
.FirstOrDefaultAsync();
|
||||
var inRange = rows.Where(m => m.CreatedAt >= from && m.CreatedAt < toExclusive);
|
||||
var received = await inRange.Where(m => m.ToLocationId == locationId).SumAsync(m => (decimal?)m.Quantity) ?? 0;
|
||||
var issued = await inRange.Where(m => m.FromLocationId == locationId).SumAsync(m => (decimal?)m.Quantity) ?? 0;
|
||||
var current = await db.StockBalances.AsNoTracking()
|
||||
.Where(b => b.FK_ItemId == itemId && b.LocationId == locationId)
|
||||
.SumAsync(b => (decimal?)b.Quantity) ?? 0;
|
||||
|
||||
return new MovementSummary(before, received, issued, before + received - issued, current);
|
||||
}
|
||||
|
||||
public Task<List<StockMovement>> GetMovementsByReferenceAsync(Guid referenceId, Guid itemId, MovementType type) =>
|
||||
db.StockMovements.AsNoTracking()
|
||||
.Where(m => m.ReferenceId == referenceId && m.FK_ItemId == itemId && m.Type == type)
|
||||
.ToListAsync();
|
||||
|
||||
public Task<Guid?> GetLastWarehouseSourceAsync(Guid vehicleId, Guid itemId) =>
|
||||
db.StockMovements.AsNoTracking()
|
||||
.Where(m => m.ToLocationId == vehicleId && m.FK_ItemId == itemId
|
||||
&& m.FromLocationType == LocationType.Warehouse)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.Select(m => m.FromLocationId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public Task<ItemBatch?> FindBatchAsync(Guid itemId, string batchNumber) =>
|
||||
db.ItemBatches.FirstOrDefaultAsync(b => b.FK_ItemId == itemId && b.BatchNumber == batchNumber);
|
||||
|
||||
public async Task AddItemBatchAsync(ItemBatch batch) =>
|
||||
await db.ItemBatches.AddAsync(batch);
|
||||
|
||||
public Task<ItemSerialNumber?> GetSerialAsync(Guid serialId) =>
|
||||
db.ItemSerialNumbers.FirstOrDefaultAsync(s => s.Id == serialId);
|
||||
|
||||
public Task<bool> SerialNumberExistsAsync(Guid itemId, string serialNumber) =>
|
||||
db.ItemSerialNumbers.AnyAsync(s => s.FK_ItemId == itemId && s.SerialNumber == serialNumber);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public class StockService(
|
||||
ICategoryRepository categoryRepo,
|
||||
IWarehouseRepository warehouseRepo,
|
||||
IVehicleRepository vehicleRepo,
|
||||
StockMover mover,
|
||||
IUnitOfWork uow)
|
||||
{
|
||||
private static StockBalanceResponse MapBalance(StockBalance b, string locationName) =>
|
||||
@@ -37,7 +38,9 @@ public class StockService(
|
||||
private static StockMovementResponse MapMovement(StockMovement m, string? fromLocationName, string? toLocationName) =>
|
||||
new(m.Id, m.FK_ItemId, m.Item.Name, m.FromLocationId, m.FromLocationType,
|
||||
m.ToLocationId, m.ToLocationType, m.Quantity, m.Type, m.ReasonCode,
|
||||
m.ReferenceId, m.CreatedAt, m.CreatedBy, fromLocationName, toLocationName);
|
||||
m.ReferenceId, m.CreatedAt, m.CreatedBy, fromLocationName, toLocationName,
|
||||
m.FK_ItemBatchId, m.ItemBatch?.BatchNumber, m.ItemBatch?.ExpiryDate,
|
||||
m.FK_ItemSerialNumberId, m.ItemSerialNumber?.SerialNumber);
|
||||
|
||||
private async Task<StockMovementResponse> MapMovementAsync(StockMovement m)
|
||||
{
|
||||
@@ -112,11 +115,16 @@ public class StockService(
|
||||
balances.Select(b => MapBalance(b, names.GetValueOrDefault(b.LocationId, "—"))).ToList());
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<StockMovementResponse>> GetMovementsAsync(
|
||||
Guid? locationId, Guid? itemId, MovementType? type, DateTime? from, DateTime? to, int page, int pageSize)
|
||||
public async Task<MovementSummary> GetMovementSummaryAsync(Guid itemId, Guid locationId, DateTime from, DateTime to)
|
||||
{
|
||||
var items = await repo.GetMovementsAsync(locationId, itemId, type, from, to, page, pageSize);
|
||||
var total = await repo.GetMovementsCountAsync(locationId, itemId, type, from, to);
|
||||
var toExclusive = to.TimeOfDay == TimeSpan.Zero ? to.AddDays(1) : to;
|
||||
return await repo.GetMovementSummaryAsync(itemId, locationId, from, toExclusive);
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<StockMovementResponse>> GetMovementsAsync(MovementFilter filter, int page, int pageSize)
|
||||
{
|
||||
var items = await repo.GetMovementsAsync(filter, page, pageSize);
|
||||
var total = await repo.GetMovementsCountAsync(filter);
|
||||
|
||||
var locations = new List<(Guid, LocationType)>();
|
||||
foreach (var m in items)
|
||||
@@ -137,60 +145,42 @@ public class StockService(
|
||||
|
||||
public async Task<StockMovementResponse> TransferAsync(TransferRequest request, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
await EnsureStockAsync(request.ItemId, request.FromLocationId, request.Quantity);
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = request.FromLocationId,
|
||||
FromLocationType = request.FromLocationType,
|
||||
ToLocationId = request.ToLocationId,
|
||||
ToLocationType = request.ToLocationType,
|
||||
Quantity = request.Quantity,
|
||||
Type = MovementType.Transfer,
|
||||
ReferenceId = request.ReferenceId,
|
||||
CreatedBy = userId
|
||||
};
|
||||
var item = await itemRepo.GetByIdAsync(request.ItemId)
|
||||
?? throw new InvalidOperationException("Item not found.");
|
||||
|
||||
List<StockMovement> movements;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await ApplyTransferAsync(request.ItemId, request.FromLocationId, request.ToLocationId, request.ToLocationType, request.Quantity);
|
||||
await repo.AddMovementAsync(movement);
|
||||
movements = await mover.MoveAsync(request.ItemId, item.Name,
|
||||
request.FromLocationId, request.FromLocationType,
|
||||
request.ToLocationId, request.ToLocationType,
|
||||
request.Quantity, MovementType.Transfer, request.ReferenceId, userId);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return await MapMovementAsync(movement);
|
||||
return await MapMovementsAsync(movements, item, request.Quantity);
|
||||
}
|
||||
|
||||
public async Task<StockMovementResponse> RecordDamageAsync(DamageRequest request, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
await EnsureStockAsync(request.ItemId, request.LocationId, request.Quantity);
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = request.LocationId,
|
||||
FromLocationType = request.LocationType,
|
||||
ToLocationId = ExternalLocationId,
|
||||
ToLocationType = LocationType.External,
|
||||
Quantity = request.Quantity,
|
||||
Type = MovementType.Damage,
|
||||
ReasonCode = request.ReasonCode,
|
||||
CreatedBy = userId
|
||||
};
|
||||
var item = await itemRepo.GetByIdAsync(request.ItemId)
|
||||
?? throw new InvalidOperationException("Item not found.");
|
||||
|
||||
List<StockMovement> movements;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await DebitBalanceAsync(request.ItemId, request.LocationId, request.Quantity);
|
||||
await repo.AddMovementAsync(movement);
|
||||
movements = await mover.MoveAsync(request.ItemId, item.Name,
|
||||
request.LocationId, request.LocationType,
|
||||
ExternalLocationId, LocationType.External,
|
||||
request.Quantity, MovementType.Damage, null, userId, request.ReasonCode);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return await MapMovementAsync(movement);
|
||||
return await MapMovementsAsync(movements, item, request.Quantity);
|
||||
}
|
||||
|
||||
public async Task<StockMovementResponse> RecordCustomerReturnAsync(CustomerReturnRequest request, Guid userId, CancellationToken ct = default)
|
||||
@@ -204,75 +194,89 @@ public class StockService(
|
||||
if (!category.AllowCustomerReturn)
|
||||
throw new InvalidOperationException($"Customer returns are not allowed for category '{category.Name}'.");
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = ExternalLocationId,
|
||||
FromLocationType = LocationType.External,
|
||||
ToLocationId = request.VehicleId,
|
||||
ToLocationType = LocationType.Vehicle,
|
||||
Quantity = request.Quantity,
|
||||
Type = MovementType.CustomerReturn,
|
||||
ReferenceId = request.ReferenceId,
|
||||
CreatedBy = userId
|
||||
};
|
||||
var tracked = item.TracksSerialNumbers || item.TracksBatches || item.TracksExpiryDate;
|
||||
if (tracked && request.ReferenceId is null)
|
||||
throw new InvalidOperationException(
|
||||
$"'{item.Name}' is batch/serial tracked — a customer return must reference the ShopPO it was delivered on.");
|
||||
|
||||
List<StockMovement> movements;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await CreditBalanceAsync(request.ItemId, request.VehicleId, LocationType.Vehicle, request.Quantity);
|
||||
await repo.AddMovementAsync(movement);
|
||||
if (tracked)
|
||||
{
|
||||
movements = await mover.ReturnToVehicleAsync(request.ItemId, item.Name, request.Quantity,
|
||||
request.ReferenceId!.Value, userId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = ExternalLocationId,
|
||||
FromLocationType = LocationType.External,
|
||||
ToLocationId = request.VehicleId,
|
||||
ToLocationType = LocationType.Vehicle,
|
||||
Quantity = request.Quantity,
|
||||
Type = MovementType.CustomerReturn,
|
||||
ReferenceId = request.ReferenceId,
|
||||
CreatedBy = userId
|
||||
};
|
||||
await CreditBalanceAsync(request.ItemId, request.VehicleId, LocationType.Vehicle, request.Quantity);
|
||||
await repo.AddMovementAsync(movement);
|
||||
movements = [movement];
|
||||
}
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return await MapMovementAsync(movement);
|
||||
return await MapMovementsAsync(movements, item, request.Quantity);
|
||||
}
|
||||
|
||||
public async Task<StockMovementResponse> AdjustAsync(AdjustmentRequest request, Guid userId, CancellationToken ct = default)
|
||||
{
|
||||
var balance = await repo.GetBalanceAsync(request.ItemId, request.LocationId);
|
||||
if (balance is not null && balance.Quantity + request.Quantity < 0)
|
||||
throw new InvalidOperationException("Adjustment would result in negative stock.");
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = request.Quantity < 0 ? request.LocationId : ExternalLocationId,
|
||||
FromLocationType = request.Quantity < 0 ? request.LocationType : LocationType.External,
|
||||
ToLocationId = request.Quantity > 0 ? request.LocationId : ExternalLocationId,
|
||||
ToLocationType = request.Quantity > 0 ? request.LocationType : LocationType.External,
|
||||
Quantity = Math.Abs(request.Quantity),
|
||||
Type = MovementType.Adjustment,
|
||||
ReasonCode = request.ReasonCode,
|
||||
CreatedBy = userId
|
||||
};
|
||||
var item = await itemRepo.GetByIdAsync(request.ItemId)
|
||||
?? throw new InvalidOperationException("Item not found.");
|
||||
|
||||
List<StockMovement> movements;
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
if (balance is null)
|
||||
if (request.Quantity < 0)
|
||||
{
|
||||
await repo.AddBalanceAsync(new StockBalance
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
LocationId = request.LocationId,
|
||||
LocationType = request.LocationType,
|
||||
Quantity = request.Quantity
|
||||
});
|
||||
movements = await mover.MoveAsync(request.ItemId, item.Name,
|
||||
request.LocationId, request.LocationType,
|
||||
ExternalLocationId, LocationType.External,
|
||||
-request.Quantity, MovementType.Adjustment, null, userId, request.ReasonCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
balance.Quantity += request.Quantity;
|
||||
balance.UpdatedAt = DateTime.Now;
|
||||
repo.UpdateBalance(balance);
|
||||
// A positive adjustment can't say which batch/serial it adds — those enter stock through a GRN.
|
||||
if (item.TracksSerialNumbers || item.TracksBatches || item.TracksExpiryDate)
|
||||
throw new InvalidOperationException(
|
||||
$"'{item.Name}' is batch/serial tracked — increase its stock by receiving a GRN, not by adjustment.");
|
||||
|
||||
var movement = new StockMovement
|
||||
{
|
||||
FK_ItemId = request.ItemId,
|
||||
FromLocationId = ExternalLocationId,
|
||||
FromLocationType = LocationType.External,
|
||||
ToLocationId = request.LocationId,
|
||||
ToLocationType = request.LocationType,
|
||||
Quantity = request.Quantity,
|
||||
Type = MovementType.Adjustment,
|
||||
ReasonCode = request.ReasonCode,
|
||||
CreatedBy = userId
|
||||
};
|
||||
await CreditBalanceAsync(request.ItemId, request.LocationId, request.LocationType, request.Quantity);
|
||||
await repo.AddMovementAsync(movement);
|
||||
movements = [movement];
|
||||
}
|
||||
await repo.AddMovementAsync(movement);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return await MapMovementAsync(movement);
|
||||
return await MapMovementsAsync(movements, item, Math.Abs(request.Quantity));
|
||||
}
|
||||
|
||||
// Movements are an immutable ledger — only the reason/note can be edited, never quantity/locations/type.
|
||||
@@ -282,28 +286,29 @@ public class StockService(
|
||||
?? throw new InvalidOperationException("Movement not found.");
|
||||
|
||||
movement.ReasonCode = request.ReasonCode;
|
||||
repo.UpdateMovement(movement);
|
||||
await uow.SaveChangesAsync(ct);
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
repo.UpdateMovement(movement);
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch { await uow.RollbackAsync(ct); throw; }
|
||||
|
||||
return await MapMovementAsync(movement);
|
||||
}
|
||||
|
||||
// ── Helpers ────────────────────────────────────────────────────────────
|
||||
|
||||
private async Task EnsureStockAsync(Guid itemId, Guid locationId, decimal quantity)
|
||||
/// <summary>
|
||||
/// One logical operation can produce several movements (one per batch/serial slice). The caller gets a
|
||||
/// single response for the operation: the first slice's locations, with the total quantity moved.
|
||||
/// </summary>
|
||||
private async Task<StockMovementResponse> MapMovementsAsync(List<StockMovement> movements, Models.Item item, decimal totalQuantity)
|
||||
{
|
||||
var balance = await repo.GetBalanceAsync(itemId, locationId);
|
||||
if (balance is null || balance.Quantity < quantity)
|
||||
throw new InvalidOperationException("Insufficient stock at the specified location.");
|
||||
}
|
||||
|
||||
private async Task DebitBalanceAsync(Guid itemId, Guid locationId, decimal quantity)
|
||||
{
|
||||
var balance = await repo.GetBalanceAsync(itemId, locationId)
|
||||
?? throw new InvalidOperationException("No stock balance found.");
|
||||
balance.Quantity -= quantity;
|
||||
balance.UpdatedAt = DateTime.Now;
|
||||
repo.UpdateBalance(balance);
|
||||
var first = movements[0];
|
||||
first.Item ??= item;
|
||||
return (await MapMovementAsync(first)) with { Quantity = totalQuantity };
|
||||
}
|
||||
|
||||
private async Task CreditBalanceAsync(Guid itemId, Guid locationId, LocationType locationType, decimal quantity)
|
||||
@@ -326,10 +331,4 @@ public class StockService(
|
||||
repo.UpdateBalance(balance);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ApplyTransferAsync(Guid itemId, Guid fromLocationId, Guid toLocationId, LocationType toLocationType, decimal quantity)
|
||||
{
|
||||
await DebitBalanceAsync(itemId, fromLocationId, quantity);
|
||||
await CreditBalanceAsync(itemId, toLocationId, toLocationType, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Distribution.Features.StockReport;
|
||||
|
||||
public record LedgerAggregate(
|
||||
Guid ItemId, string Sku, string Name, string? Brand, string Category, string Uom,
|
||||
decimal? CostPrice, decimal? ReorderLevel,
|
||||
decimal Opening, decimal In, decimal Out, decimal Current, decimal WarehouseQty);
|
||||
|
||||
public record ExpiryAggregate(
|
||||
Guid ItemId, string Sku, string Name, Guid BatchId, string? BatchNumber, DateTime ExpiryDate,
|
||||
decimal Quantity, decimal? CostPrice, Guid LocationId, string LocationType, string LocationName);
|
||||
|
||||
public record OverviewAggregate(
|
||||
int ActiveItems, int InStockItems, int LowStockItems, decimal TotalQty, decimal TotalValue,
|
||||
int ExpiringSoonBatches, int ExpiredBatches);
|
||||
|
||||
public interface IStockReportRepository
|
||||
{
|
||||
Task<bool> IsWarehouseAsync(Guid locationId);
|
||||
Task<OverviewAggregate> GetOverviewAsync(Guid? locationId, bool includeWarehouseLow, DateTime today, int expiryDays);
|
||||
Task<(List<LedgerAggregate> Rows, int Total)> GetLedgerAsync(StockReportFilter f, bool includeWarehouseLow, int page, int pageSize);
|
||||
Task<(List<ExpiryAggregate> Rows, int Total)> GetExpiryAsync(Guid? locationId, string? search, DateTime cutoff, int page, int pageSize);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.StockReport;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/reports/stock")]
|
||||
public class StockReportController(StockReportService service) : ControllerBase
|
||||
{
|
||||
[HttpGet("overview")]
|
||||
public async Task<IActionResult> Overview([FromQuery] Guid? locationId, [FromQuery] int expiryDays = 30)
|
||||
{
|
||||
var error = StockReportService.ValidateExpiry(expiryDays, 1, 1);
|
||||
return error is null ? Ok(await service.GetOverviewAsync(locationId, expiryDays)) : BadRequest(new { message = error });
|
||||
}
|
||||
|
||||
[HttpGet("ledger")]
|
||||
public async Task<IActionResult> Ledger(
|
||||
[FromQuery] Guid? locationId, [FromQuery] Guid? categoryId, [FromQuery] Guid? brandId,
|
||||
[FromQuery] DateTime? from, [FromQuery] DateTime? to, [FromQuery] string? status = null,
|
||||
[FromQuery] bool activeOnly = true, [FromQuery] string? search = null,
|
||||
[FromQuery] int page = 1, [FromQuery] int pageSize = 50)
|
||||
{
|
||||
var end = (to ?? DateTime.Now).Date;
|
||||
var start = (from ?? end.AddDays(-30)).Date;
|
||||
var f = new StockReportFilter(locationId, categoryId, brandId, search, start, end, status, activeOnly);
|
||||
var error = StockReportService.Validate(f, page, pageSize);
|
||||
return error is null ? Ok(await service.GetLedgerAsync(f, page, pageSize)) : BadRequest(new { message = error });
|
||||
}
|
||||
|
||||
[HttpGet("expiry")]
|
||||
public async Task<IActionResult> Expiry(
|
||||
[FromQuery] Guid? locationId, [FromQuery] string? search = null, [FromQuery] int days = 30,
|
||||
[FromQuery] int page = 1, [FromQuery] int pageSize = 50)
|
||||
{
|
||||
var error = StockReportService.ValidateExpiry(days, page, pageSize);
|
||||
return error is null
|
||||
? Ok(await service.GetExpiryAsync(locationId, search, days, page, pageSize))
|
||||
: BadRequest(new { message = error });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Distribution.Features.StockReport;
|
||||
|
||||
public static class StockStatus
|
||||
{
|
||||
public const string Ok = "OK";
|
||||
public const string Low = "Low";
|
||||
public const string Out = "Out";
|
||||
}
|
||||
|
||||
public record StockReportFilter(
|
||||
Guid? LocationId, Guid? CategoryId, Guid? BrandId, string? Search,
|
||||
DateTime From, DateTime To, string? Status, bool ActiveOnly);
|
||||
|
||||
public record StockOverview(
|
||||
int TotalSkus, decimal TotalQty, decimal TotalValue,
|
||||
int LowStockCount, int OutOfStockCount, int ExpiringSoonCount, int ExpiredCount);
|
||||
|
||||
public record StockLedgerRow(
|
||||
Guid ItemId, string Sku, string Name, string? Brand, string Category, string Uom,
|
||||
decimal OpeningQty, decimal QtyIn, decimal QtyOut, decimal ClosingQty, decimal CurrentQty,
|
||||
decimal? CostPrice, decimal StockValue, decimal? ReorderLevel, string Status);
|
||||
|
||||
public record StockExpiryRow(
|
||||
Guid ItemId, string Sku, string Name, Guid BatchId, string? BatchNumber, DateTime ExpiryDate, int DaysLeft,
|
||||
decimal Quantity, decimal? CostPrice, decimal Value, Guid LocationId, string LocationType, string LocationName);
|
||||
@@ -0,0 +1,182 @@
|
||||
using System.Linq.Expressions;
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.StockReport;
|
||||
|
||||
public class StockReportRepository(AppDBContext db) : IStockReportRepository
|
||||
{
|
||||
// One location when picked, otherwise every internal location (warehouses + vehicles; External is not tracked).
|
||||
private IQueryable<StockBalance> ScopedBalances(Guid? locationId)
|
||||
{
|
||||
var q = db.StockBalances.AsNoTracking().AsQueryable();
|
||||
return locationId.HasValue
|
||||
? q.Where(b => b.LocationId == locationId.Value)
|
||||
: q.Where(b => b.LocationType == LocationType.Warehouse || b.LocationType == LocationType.Vehicle);
|
||||
}
|
||||
|
||||
public Task<bool> IsWarehouseAsync(Guid locationId) =>
|
||||
db.Warehouses.AsNoTracking().AnyAsync(w => w.Id == locationId);
|
||||
|
||||
public async Task<OverviewAggregate> GetOverviewAsync(Guid? locationId, bool includeWarehouseLow, DateTime today, int expiryDays)
|
||||
{
|
||||
var balances = ScopedBalances(locationId);
|
||||
var whBalances = balances.Where(b => b.LocationType == LocationType.Warehouse);
|
||||
|
||||
var perItem = db.Items.AsNoTracking().Where(i => i.IsActive).Select(i => new
|
||||
{
|
||||
i.ReorderLevel,
|
||||
i.CostPrice,
|
||||
Qty = balances.Where(b => b.FK_ItemId == i.Id).Sum(b => (decimal?)b.Quantity) ?? 0m,
|
||||
Wh = whBalances.Where(b => b.FK_ItemId == i.Id).Sum(b => (decimal?)b.Quantity) ?? 0m,
|
||||
});
|
||||
|
||||
var activeItems = await perItem.CountAsync();
|
||||
var inStockItems = await perItem.CountAsync(x => x.Qty > 0);
|
||||
var lowItems = includeWarehouseLow
|
||||
? await perItem.CountAsync(x => x.Qty > 0 && x.ReorderLevel != null && x.Wh <= x.ReorderLevel)
|
||||
: 0;
|
||||
var totalQty = await perItem.SumAsync(x => (decimal?)x.Qty) ?? 0m;
|
||||
var totalValue = await perItem.SumAsync(x => (decimal?)(x.Qty * (x.CostPrice ?? 0m))) ?? 0m;
|
||||
|
||||
var soonEnd = today.AddDays(expiryDays + 1);
|
||||
var batchBalances = balances.Where(b => b.FK_ItemBatchId != null && b.Quantity > 0
|
||||
&& b.ItemBatch!.ExpiryDate != null);
|
||||
var expired = await batchBalances.Where(b => b.ItemBatch!.ExpiryDate < today)
|
||||
.Select(b => b.FK_ItemBatchId).Distinct().CountAsync();
|
||||
var soon = await batchBalances.Where(b => b.ItemBatch!.ExpiryDate >= today && b.ItemBatch.ExpiryDate < soonEnd)
|
||||
.Select(b => b.FK_ItemBatchId).Distinct().CountAsync();
|
||||
|
||||
return new OverviewAggregate(activeItems, inStockItems, lowItems, totalQty, totalValue, soon, expired);
|
||||
}
|
||||
|
||||
public async Task<(List<LedgerAggregate> Rows, int Total)> GetLedgerAsync(
|
||||
StockReportFilter f, bool includeWarehouseLow, int page, int pageSize)
|
||||
{
|
||||
var balances = ScopedBalances(f.LocationId);
|
||||
var whBalances = balances.Where(b => b.LocationType == LocationType.Warehouse);
|
||||
|
||||
var items = db.Items.AsNoTracking().AsQueryable();
|
||||
if (f.ActiveOnly) items = items.Where(i => i.IsActive);
|
||||
if (f.CategoryId.HasValue) items = items.Where(i => i.FK_CategoryId == f.CategoryId.Value);
|
||||
if (f.BrandId.HasValue) items = items.Where(i => i.FK_BrandId == f.BrandId.Value);
|
||||
if (!string.IsNullOrWhiteSpace(f.Search))
|
||||
{
|
||||
var s = f.Search.Trim();
|
||||
items = items.Where(i => i.Name.Contains(s) || i.Sku.Contains(s));
|
||||
}
|
||||
|
||||
var withQty = items.Select(i => new
|
||||
{
|
||||
Item = i,
|
||||
Qty = balances.Where(b => b.FK_ItemId == i.Id).Sum(b => (decimal?)b.Quantity) ?? 0m,
|
||||
Wh = whBalances.Where(b => b.FK_ItemId == i.Id).Sum(b => (decimal?)b.Quantity) ?? 0m,
|
||||
});
|
||||
|
||||
if (f.Status == "out")
|
||||
withQty = withQty.Where(x => x.Qty <= 0);
|
||||
else if (f.Status == "low")
|
||||
withQty = includeWarehouseLow
|
||||
? withQty.Where(x => x.Qty > 0 && x.Item.ReorderLevel != null && x.Wh <= x.Item.ReorderLevel)
|
||||
: withQty.Where(x => false);
|
||||
|
||||
var total = await withQty.CountAsync();
|
||||
var pageRows = await withQty
|
||||
.OrderBy(x => x.Item.Name)
|
||||
.Skip((page - 1) * pageSize).Take(pageSize)
|
||||
.Select(x => new
|
||||
{
|
||||
x.Item.Id, x.Item.Sku, x.Item.Name,
|
||||
Brand = x.Item.Brand != null ? x.Item.Brand.Name : null,
|
||||
Category = x.Item.Category.Name,
|
||||
Uom = x.Item.BaseUom.Name,
|
||||
x.Item.CostPrice, x.Item.ReorderLevel,
|
||||
x.Qty, x.Wh,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var ids = pageRows.Select(r => r.Id).ToList();
|
||||
var toExclusive = f.To.TimeOfDay == TimeSpan.Zero ? f.To.AddDays(1) : f.To;
|
||||
var from = f.From;
|
||||
|
||||
Expression<Func<StockMovement, bool>> isIn, isOut;
|
||||
if (f.LocationId.HasValue)
|
||||
{
|
||||
var loc = f.LocationId.Value;
|
||||
isIn = m => m.ToLocationId == loc;
|
||||
isOut = m => m.FromLocationId == loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// All locations: only movements that cross the boundary of the internal network count;
|
||||
// warehouse <-> vehicle transfers net to zero and are left out of in/out.
|
||||
isIn = m => m.ToLocationId != null && m.ToLocationType != LocationType.External
|
||||
&& (m.FromLocationId == null || m.FromLocationType == LocationType.External);
|
||||
isOut = m => m.FromLocationId != null && m.FromLocationType != LocationType.External
|
||||
&& (m.ToLocationId == null || m.ToLocationType == LocationType.External);
|
||||
}
|
||||
|
||||
var moves = db.StockMovements.AsNoTracking().Where(m => ids.Contains(m.FK_ItemId) && m.CreatedAt < toExclusive);
|
||||
var before = moves.Where(m => m.CreatedAt < from);
|
||||
var inRange = moves.Where(m => m.CreatedAt >= from);
|
||||
|
||||
var openingIn = await SumByItem(before, isIn);
|
||||
var openingOut = await SumByItem(before, isOut);
|
||||
var rangeIn = await SumByItem(inRange, isIn);
|
||||
var rangeOut = await SumByItem(inRange, isOut);
|
||||
|
||||
var rows = pageRows.Select(r => new LedgerAggregate(
|
||||
r.Id, r.Sku, r.Name, r.Brand, r.Category, r.Uom, r.CostPrice, r.ReorderLevel,
|
||||
openingIn.GetValueOrDefault(r.Id) - openingOut.GetValueOrDefault(r.Id),
|
||||
rangeIn.GetValueOrDefault(r.Id), rangeOut.GetValueOrDefault(r.Id),
|
||||
r.Qty, r.Wh)).ToList();
|
||||
return (rows, total);
|
||||
}
|
||||
|
||||
private static async Task<Dictionary<Guid, decimal>> SumByItem(
|
||||
IQueryable<StockMovement> q, Expression<Func<StockMovement, bool>> predicate) =>
|
||||
await q.Where(predicate)
|
||||
.GroupBy(m => m.FK_ItemId)
|
||||
.Select(g => new { ItemId = g.Key, Qty = g.Sum(m => m.Quantity) })
|
||||
.ToDictionaryAsync(x => x.ItemId, x => x.Qty);
|
||||
|
||||
public async Task<(List<ExpiryAggregate> Rows, int Total)> GetExpiryAsync(
|
||||
Guid? locationId, string? search, DateTime cutoffExclusive, int page, int pageSize)
|
||||
{
|
||||
var q = ScopedBalances(locationId)
|
||||
.Where(b => b.FK_ItemBatchId != null && b.Quantity > 0
|
||||
&& b.ItemBatch!.ExpiryDate != null && b.ItemBatch.ExpiryDate < cutoffExclusive);
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
var s = search.Trim();
|
||||
q = q.Where(b => b.Item.Name.Contains(s) || b.Item.Sku.Contains(s));
|
||||
}
|
||||
|
||||
var total = await q.CountAsync();
|
||||
var page_ = await q
|
||||
.OrderBy(b => b.ItemBatch!.ExpiryDate).ThenBy(b => b.Item.Name)
|
||||
.Skip((page - 1) * pageSize).Take(pageSize)
|
||||
.Select(b => new
|
||||
{
|
||||
b.FK_ItemId, b.Item.Sku, b.Item.Name,
|
||||
BatchId = b.FK_ItemBatchId!.Value,
|
||||
b.ItemBatch!.BatchNumber,
|
||||
ExpiryDate = b.ItemBatch.ExpiryDate!.Value,
|
||||
b.Quantity, b.Item.CostPrice, b.LocationId, b.LocationType,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var locIds = page_.Select(r => r.LocationId).Distinct().ToList();
|
||||
var names = await db.Warehouses.AsNoTracking().Where(w => locIds.Contains(w.Id))
|
||||
.Select(w => new { w.Id, w.Name }).ToDictionaryAsync(w => w.Id, w => w.Name);
|
||||
var plates = await db.Vehicles.AsNoTracking().Where(v => locIds.Contains(v.Id))
|
||||
.Select(v => new { v.Id, v.NumberPlate }).ToDictionaryAsync(v => v.Id, v => v.NumberPlate);
|
||||
|
||||
var rows = page_.Select(r => new ExpiryAggregate(
|
||||
r.FK_ItemId, r.Sku, r.Name, r.BatchId, r.BatchNumber, r.ExpiryDate,
|
||||
r.Quantity, r.CostPrice, r.LocationId, r.LocationType.ToString(),
|
||||
names.GetValueOrDefault(r.LocationId) ?? plates.GetValueOrDefault(r.LocationId) ?? "—")).ToList();
|
||||
return (rows, total);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Distribution.Features.Stock;
|
||||
|
||||
namespace Distribution.Features.StockReport;
|
||||
|
||||
public class StockReportService(IStockReportRepository repo)
|
||||
{
|
||||
public const int MaxRangeDays = 366;
|
||||
public const int MaxExpiryDays = 3650;
|
||||
|
||||
public static string? Validate(StockReportFilter f, int page, int pageSize)
|
||||
{
|
||||
if (page < 1 || pageSize < 1 || pageSize > 200) return "page must be >= 1 and pageSize between 1 and 200.";
|
||||
if (f.To < f.From) return "'to' must not be before 'from'.";
|
||||
if ((f.To - f.From).TotalDays > MaxRangeDays) return $"Date range cannot exceed {MaxRangeDays} days.";
|
||||
if (f.Status is not (null or "low" or "out")) return "status must be 'low' or 'out'.";
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string? ValidateExpiry(int days, int page, int pageSize)
|
||||
{
|
||||
if (page < 1 || pageSize < 1 || pageSize > 200) return "page must be >= 1 and pageSize between 1 and 200.";
|
||||
if (days < 0 || days > MaxExpiryDays) return $"days must be between 0 and {MaxExpiryDays}.";
|
||||
return null;
|
||||
}
|
||||
|
||||
// Low-stock is judged on warehouse quantity, so it only applies when the scope includes warehouses.
|
||||
private async Task<bool> IncludesWarehouses(Guid? locationId) =>
|
||||
!locationId.HasValue || await repo.IsWarehouseAsync(locationId.Value);
|
||||
|
||||
public async Task<StockOverview> GetOverviewAsync(Guid? locationId, int expiryDays)
|
||||
{
|
||||
var agg = await repo.GetOverviewAsync(locationId, await IncludesWarehouses(locationId), DateTime.Now.Date, expiryDays);
|
||||
return new StockOverview(agg.InStockItems, agg.TotalQty, agg.TotalValue, agg.LowStockItems,
|
||||
agg.ActiveItems - agg.InStockItems, agg.ExpiringSoonBatches, agg.ExpiredBatches);
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<StockLedgerRow>> GetLedgerAsync(StockReportFilter f, int page, int pageSize)
|
||||
{
|
||||
var includeLow = await IncludesWarehouses(f.LocationId);
|
||||
var (rows, total) = await repo.GetLedgerAsync(f, includeLow, page, pageSize);
|
||||
var mapped = rows.Select(r =>
|
||||
{
|
||||
var status = r.Current <= 0 ? StockStatus.Out
|
||||
: includeLow && r.ReorderLevel != null && r.WarehouseQty <= r.ReorderLevel ? StockStatus.Low
|
||||
: StockStatus.Ok;
|
||||
return new StockLedgerRow(r.ItemId, r.Sku, r.Name, r.Brand, r.Category, r.Uom,
|
||||
r.Opening, r.In, r.Out, r.Opening + r.In - r.Out, r.Current,
|
||||
r.CostPrice, r.Current * (r.CostPrice ?? 0m), r.ReorderLevel, status);
|
||||
}).ToList();
|
||||
return new PagedResponse<StockLedgerRow>(page, pageSize, total, mapped);
|
||||
}
|
||||
|
||||
public async Task<PagedResponse<StockExpiryRow>> GetExpiryAsync(
|
||||
Guid? locationId, string? search, int days, int page, int pageSize)
|
||||
{
|
||||
var today = DateTime.Now.Date;
|
||||
var (rows, total) = await repo.GetExpiryAsync(locationId, search, today.AddDays(days + 1), page, pageSize);
|
||||
var mapped = rows.Select(r => new StockExpiryRow(
|
||||
r.ItemId, r.Sku, r.Name, r.BatchId, r.BatchNumber, r.ExpiryDate,
|
||||
(int)(r.ExpiryDate.Date - today).TotalDays,
|
||||
r.Quantity, r.CostPrice, r.Quantity * (r.CostPrice ?? 0m),
|
||||
r.LocationId, r.LocationType, r.LocationName)).ToList();
|
||||
return new PagedResponse<StockExpiryRow>(page, pageSize, total, mapped);
|
||||
}
|
||||
}
|
||||
@@ -13,4 +13,5 @@ public interface IStoreRepository
|
||||
void Update(Models.Store entity);
|
||||
void Remove(Models.Store entity);
|
||||
Task<List<Models.ShopPO>> GetOrdersForDashboardAsync(Guid storeId, DateTime periodStart, DateTime periodEndExclusive);
|
||||
Task<List<Models.Invoice>> GetInvoicesForAnalyticsAsync(Guid storeId);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.Store;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/stores")]
|
||||
public class StoreController(
|
||||
StoreService service,
|
||||
IScopeAccessService scopeAccess,
|
||||
ICurrentUserService currentUser) : ControllerBase
|
||||
public class StoreController(StoreService service) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> GetAll(
|
||||
[FromQuery] Guid? routeId,
|
||||
[FromQuery] string? search,
|
||||
@@ -22,18 +16,13 @@ public class StoreController(
|
||||
Ok(await service.GetAllAsync(routeId, search, page, pageSize));
|
||||
|
||||
[HttpGet("{id:guid}")]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var userId = currentUser.UserId;
|
||||
if (userId.HasValue && !await scopeAccess.HasStoreScopeAsync(userId.Value, id))
|
||||
return StatusCode(403);
|
||||
var result = await service.GetByIdAsync(id);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> Create(CreateStoreRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.CreateAsync(request, ct);
|
||||
@@ -41,7 +30,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateStoreRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateAsync(id, request, ct);
|
||||
@@ -49,7 +37,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
|
||||
{
|
||||
var deleted = await service.DeleteAsync(id, ct);
|
||||
@@ -57,7 +44,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/credit-limit")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> UpdateCreditLimit(Guid id, UpdateCreditLimitRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateCreditLimitAsync(id, request, ct);
|
||||
@@ -65,7 +51,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/outstanding-balance")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> UpdateOutstandingBalance(Guid id, UpdateOutstandingBalanceRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.UpdateOutstandingBalanceAsync(id, request, ct);
|
||||
@@ -73,7 +58,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/outstanding-balance")]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> GetOutstandingBalance(Guid id)
|
||||
{
|
||||
var result = await service.GetOutstandingBalanceAsync(id);
|
||||
@@ -81,7 +65,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpPut("{id:guid}/segment")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> ClassifySegment(Guid id, ClassifySegmentRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.ClassifySegmentAsync(id, request, ct);
|
||||
@@ -89,7 +72,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/visit-history")]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> GetVisitHistory(Guid id)
|
||||
{
|
||||
var result = await service.GetVisitHistoryAsync(id);
|
||||
@@ -97,7 +79,6 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/schemes/{schemeId:guid}/eligibility")]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> CheckSchemeEligibility(Guid id, Guid schemeId)
|
||||
{
|
||||
var result = await service.CheckSchemeEligibilityAsync(id, schemeId);
|
||||
@@ -105,15 +86,20 @@ public class StoreController(
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/dashboard")]
|
||||
[Authorize("store.view")]
|
||||
public async Task<IActionResult> GetDashboard(Guid id, [FromQuery] string period)
|
||||
{
|
||||
var result = await service.GetDashboardAsync(id, period);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/analytics")]
|
||||
public async Task<IActionResult> GetAnalytics(Guid id, [FromQuery] int months = 12, [FromQuery] int overdueDays = 30)
|
||||
{
|
||||
var result = await service.GetAnalyticsAsync(id, months, overdueDays);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPatch("{id:guid}/status")]
|
||||
[Authorize("store.manage")]
|
||||
public async Task<IActionResult> PatchStatus(Guid id, PatchStoreStatusRequest request, CancellationToken ct)
|
||||
{
|
||||
var result = await service.SetActiveStatusAsync(id, request.IsActive, ct);
|
||||
|
||||
@@ -59,3 +59,40 @@ public record SchemeEligibilityResponse(bool Eligible, string? Reason);
|
||||
public record PatchStoreStatusRequest(bool IsActive);
|
||||
|
||||
public record StoreDashboardResponse(Guid StoreId, string Period, int OrderCount, decimal TotalOrderValue, DateTime? LastOrderDate);
|
||||
|
||||
public record StoreAnalyticsSummary(
|
||||
decimal TotalSales,
|
||||
decimal TotalCollected,
|
||||
decimal Outstanding,
|
||||
decimal OverdueAmount,
|
||||
int OverdueInvoiceCount,
|
||||
int InvoiceCount,
|
||||
decimal AverageOrderValue,
|
||||
DateTime? LastSaleDate,
|
||||
decimal CreditLimit,
|
||||
decimal CreditUtilizationPercent);
|
||||
|
||||
public record StoreMonthlySales(string Month, decimal Invoiced, decimal Collected, decimal Outstanding);
|
||||
|
||||
public record StoreTopProduct(Guid ItemId, string Name, int Quantity, decimal Revenue, DateTime LastSoldAt);
|
||||
|
||||
public record StoreAgeingBucket(string Label, decimal Amount, int InvoiceCount);
|
||||
|
||||
public record StoreAnalyticsInvoice(
|
||||
Guid InvoiceId,
|
||||
DateTime InvoiceDate,
|
||||
DateTime DueDate,
|
||||
decimal TotalAmount,
|
||||
decimal PaidAmount,
|
||||
decimal Balance,
|
||||
string PaymentStatus,
|
||||
int DaysOverdue);
|
||||
|
||||
public record StoreAnalyticsResponse(
|
||||
Guid StoreId,
|
||||
int OverdueDays,
|
||||
StoreAnalyticsSummary Summary,
|
||||
List<StoreMonthlySales> MonthlySales,
|
||||
List<StoreTopProduct> TopProducts,
|
||||
List<StoreAgeingBucket> Ageing,
|
||||
List<StoreAnalyticsInvoice> Invoices);
|
||||
|
||||
@@ -51,4 +51,12 @@ public class StoreRepository(AppDBContext context) : IStoreRepository
|
||||
await context.ShopPOs
|
||||
.Where(o => o.FK_StoreId == storeId && o.IsActive && o.CreatedAt >= periodStart && o.CreatedAt < periodEndExclusive)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<List<Models.Invoice>> GetInvoicesForAnalyticsAsync(Guid storeId) =>
|
||||
await context.Invoices
|
||||
.AsNoTracking()
|
||||
.Include(i => i.Payments)
|
||||
.Include(i => i.ShopPO).ThenInclude(p => p.Items).ThenInclude(x => x.Item)
|
||||
.Where(i => i.IsActive && i.Status != InvoiceStatus.Draft && i.ShopPO.FK_StoreId == storeId)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class StoreService(IStoreRepository repo, IUnitOfWork uow, ICurrentUserSe
|
||||
private const int GlobalScopeRoleLevel = 50;
|
||||
private const int CreditApproverRoleLevel = 20;
|
||||
|
||||
private async Task<bool> HasGlobalScopeAsync() => await currentUser.GetRoleLevelAsync() >= GlobalScopeRoleLevel;
|
||||
private bool HasGlobalScope => currentUser.RoleLevel >= GlobalScopeRoleLevel;
|
||||
|
||||
private async Task<bool> HasStoreScopeAsync(Guid storeId)
|
||||
{
|
||||
@@ -122,7 +122,7 @@ public class StoreService(IStoreRepository repo, IUnitOfWork uow, ICurrentUserSe
|
||||
|
||||
public async Task<StoreResponse?> UpdateCreditLimitAsync(Guid id, UpdateCreditLimitRequest request, CancellationToken ct = default)
|
||||
{
|
||||
if (await currentUser.GetRoleLevelAsync() < CreditApproverRoleLevel) return null;
|
||||
if (currentUser.RoleLevel < CreditApproverRoleLevel) return null;
|
||||
var store = await repo.GetByIdAsync(id);
|
||||
if (store is null || !store.IsActive) return null;
|
||||
if (!await HasStoreScopeAsync(id)) return null;
|
||||
@@ -143,7 +143,7 @@ public class StoreService(IStoreRepository repo, IUnitOfWork uow, ICurrentUserSe
|
||||
|
||||
public async Task<StoreResponse?> UpdateOutstandingBalanceAsync(Guid id, UpdateOutstandingBalanceRequest request, CancellationToken ct = default)
|
||||
{
|
||||
if (await currentUser.GetRoleLevelAsync() < CreditApproverRoleLevel) return null;
|
||||
if (currentUser.RoleLevel < CreditApproverRoleLevel) return null;
|
||||
var store = await repo.GetByIdAsync(id);
|
||||
if (store is null || !store.IsActive) return null;
|
||||
if (!await HasStoreScopeAsync(id)) return null;
|
||||
@@ -253,4 +253,92 @@ public class StoreService(IStoreRepository repo, IUnitOfWork uow, ICurrentUserSe
|
||||
orders.Sum(o => o.TotalAmount),
|
||||
orders.Count == 0 ? null : orders.Max(o => o.CreatedAt));
|
||||
}
|
||||
|
||||
public async Task<StoreAnalyticsResponse?> GetAnalyticsAsync(Guid id, int months, int overdueDays)
|
||||
{
|
||||
var store = await repo.GetByIdAsync(id);
|
||||
if (store is null) return null;
|
||||
if (!await HasStoreScopeAsync(id)) return null;
|
||||
|
||||
months = Math.Clamp(months, 1, 36);
|
||||
overdueDays = Math.Clamp(overdueDays, 0, 365);
|
||||
var now = DateTime.Now;
|
||||
var from = new DateTime(now.Year, now.Month, 1).AddMonths(-(months - 1));
|
||||
|
||||
var invoices = (await repo.GetInvoicesForAnalyticsAsync(id))
|
||||
.Select(i =>
|
||||
{
|
||||
var date = i.FinalizedAt ?? i.CreatedAt;
|
||||
var paid = i.Payments.Where(p => p.IsActive).Sum(p => p.Amount);
|
||||
var balance = Math.Max(0, i.TotalAmount - paid);
|
||||
var due = date.AddDays(overdueDays);
|
||||
var daysOverdue = balance > 0 && now > due ? (int)(now - due).TotalDays : 0;
|
||||
return (Invoice: i, Date: date, Due: due, Paid: paid, Balance: balance, DaysOverdue: daysOverdue);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var inRange = invoices.Where(x => x.Date >= from).ToList();
|
||||
var totalSales = inRange.Sum(x => x.Invoice.TotalAmount);
|
||||
var overdue = invoices.Where(x => x.DaysOverdue > 0).ToList();
|
||||
|
||||
var summary = new StoreAnalyticsSummary(
|
||||
totalSales,
|
||||
inRange.Sum(x => x.Paid),
|
||||
invoices.Sum(x => x.Balance),
|
||||
overdue.Sum(x => x.Balance),
|
||||
overdue.Count,
|
||||
inRange.Count,
|
||||
inRange.Count == 0 ? 0 : Math.Round(totalSales / inRange.Count, 2),
|
||||
invoices.Count == 0 ? null : invoices.Max(x => x.Date),
|
||||
store.CreditLimit,
|
||||
store.CreditLimit > 0 ? Math.Round(store.OutstandingBalance / store.CreditLimit * 100, 1) : 0);
|
||||
|
||||
var monthly = Enumerable.Range(0, months)
|
||||
.Select(n => from.AddMonths(n))
|
||||
.Select(m => new StoreMonthlySales(
|
||||
m.ToString("yyyy-MM"),
|
||||
inRange.Where(x => x.Date.Year == m.Year && x.Date.Month == m.Month).Sum(x => x.Invoice.TotalAmount),
|
||||
inRange.Where(x => x.Date.Year == m.Year && x.Date.Month == m.Month).Sum(x => x.Paid),
|
||||
invoices
|
||||
.Where(x => x.Date < m.AddMonths(1))
|
||||
.Sum(x => Math.Max(0, x.Invoice.TotalAmount - x.Invoice.Payments.Where(p => p.IsActive && p.CollectedAt < m.AddMonths(1)).Sum(p => p.Amount)))))
|
||||
.ToList();
|
||||
|
||||
var topProducts = inRange
|
||||
.SelectMany(x => x.Invoice.ShopPO.Items.Select(it => (it, x.Date)))
|
||||
.GroupBy(t => t.it.FK_ItemId)
|
||||
.Select(g => new StoreTopProduct(
|
||||
g.Key,
|
||||
g.First().it.Item?.Name ?? "Unknown",
|
||||
g.Sum(t => t.it.QuantityFulfilled > 0 ? t.it.QuantityFulfilled : t.it.Quantity),
|
||||
g.Sum(t => (t.it.QuantityFulfilled > 0 ? t.it.QuantityFulfilled : t.it.Quantity) * t.it.UnitPrice),
|
||||
g.Max(t => t.Date)))
|
||||
.OrderByDescending(p => p.Revenue)
|
||||
.Take(10)
|
||||
.ToList();
|
||||
|
||||
var unpaid = invoices.Where(x => x.Balance > 0).ToList();
|
||||
StoreAgeingBucket Bucket(string label, Func<int, bool> match)
|
||||
{
|
||||
var items = unpaid.Where(x => match(x.DaysOverdue)).ToList();
|
||||
return new StoreAgeingBucket(label, items.Sum(x => x.Balance), items.Count);
|
||||
}
|
||||
var ageing = new List<StoreAgeingBucket>
|
||||
{
|
||||
Bucket("Current", d => d <= 0),
|
||||
Bucket("1-30", d => d is >= 1 and <= 30),
|
||||
Bucket("31-60", d => d is >= 31 and <= 60),
|
||||
Bucket("61-90", d => d is >= 61 and <= 90),
|
||||
Bucket("90+", d => d > 90)
|
||||
};
|
||||
|
||||
var list = invoices
|
||||
.OrderByDescending(x => x.Date)
|
||||
.Select(x => new StoreAnalyticsInvoice(
|
||||
x.Invoice.Id, x.Date, x.Due, x.Invoice.TotalAmount, x.Paid, x.Balance,
|
||||
x.Invoice.PaymentStatus.ToString(), x.DaysOverdue))
|
||||
.ToList();
|
||||
|
||||
return new StoreAnalyticsResponse(id, overdueDays, summary, monthly, topProducts, ageing, list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Distribution.Infra.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.SupplierClaims;
|
||||
@@ -8,12 +7,10 @@ namespace Distribution.Features.SupplierClaims;
|
||||
public class SupplierClaimController(SupplierClaimService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/supplier-claims")]
|
||||
[Authorize("supplier-claim.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
[HttpGet("api/supplier-claims/{id:guid}")]
|
||||
[Authorize("supplier-claim.view")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await service.GetByIdAsync(id);
|
||||
@@ -21,12 +18,10 @@ public class SupplierClaimController(SupplierClaimService service, ICurrentUserS
|
||||
}
|
||||
|
||||
[HttpGet("api/purchase-orders/{id:guid}/claims")]
|
||||
[Authorize("supplier-claim.view")]
|
||||
public async Task<IActionResult> GetByPurchaseOrder(Guid id) =>
|
||||
Ok(await service.GetByPurchaseOrderIdAsync(id));
|
||||
|
||||
[HttpPost("api/purchase-orders/{id:guid}/claims")]
|
||||
[Authorize("supplier-claim.manage")]
|
||||
public async Task<IActionResult> Create(Guid id, CreateSupplierClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
// TEMPORARY: currentUser.UserId is always unset due to the broken auth middleware
|
||||
@@ -42,7 +37,6 @@ public class SupplierClaimController(SupplierClaimService service, ICurrentUserS
|
||||
}
|
||||
|
||||
[HttpPut("api/supplier-claims/{id:guid}")]
|
||||
[Authorize("supplier-claim.manage")]
|
||||
public async Task<IActionResult> Update(Guid id, UpdateSupplierClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
@@ -54,7 +48,6 @@ public class SupplierClaimController(SupplierClaimService service, ICurrentUserS
|
||||
}
|
||||
|
||||
[HttpPost("api/supplier-claims/{id:guid}/approve")]
|
||||
[Authorize("supplier-claim.manage")]
|
||||
public async Task<IActionResult> Approve(Guid id, ApproveSupplierClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.ApprovedByUserId;
|
||||
@@ -69,7 +62,6 @@ public class SupplierClaimController(SupplierClaimService service, ICurrentUserS
|
||||
}
|
||||
|
||||
[HttpPost("api/supplier-claims/{id:guid}/reject")]
|
||||
[Authorize("supplier-claim.manage")]
|
||||
public async Task<IActionResult> Reject(Guid id, RejectSupplierClaimRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.RejectedByUserId;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Distribution.Infra.Authorization;
|
||||
using Distribution.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Features.SysConfig;
|
||||
@@ -10,12 +9,11 @@ namespace Distribution.Features.SysConfig;
|
||||
public class SysConfigController(SysConfigService service, ICurrentUserService currentUser) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[Authorize("sys-config.view")]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
Ok(await service.GetAllAsync());
|
||||
|
||||
// Typed shortcut — must be declared before {key} to take precedence
|
||||
[HttpGet("invoice-creation-mode")]
|
||||
[Authorize("sys-config.view")]
|
||||
public async Task<IActionResult> GetInvoiceCreationMode()
|
||||
{
|
||||
var mode = await service.GetInvoiceCreationModeAsync();
|
||||
@@ -23,7 +21,6 @@ public class SysConfigController(SysConfigService service, ICurrentUserService c
|
||||
}
|
||||
|
||||
[HttpPut("invoice-creation-mode")]
|
||||
[Authorize("sys-config.manage")]
|
||||
public async Task<IActionResult> SetInvoiceCreationMode(SetInvoiceCreationModeRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? throw new UnauthorizedAccessException();
|
||||
@@ -36,7 +33,6 @@ public class SysConfigController(SysConfigService service, ICurrentUserService c
|
||||
}
|
||||
|
||||
[HttpGet("{key}")]
|
||||
[Authorize("sys-config.view")]
|
||||
public async Task<IActionResult> GetByKey(string key)
|
||||
{
|
||||
var result = await service.GetByKeyAsync(key);
|
||||
@@ -44,7 +40,6 @@ public class SysConfigController(SysConfigService service, ICurrentUserService c
|
||||
}
|
||||
|
||||
[HttpPut("{key}")]
|
||||
[Authorize("sys-config.manage")]
|
||||
public async Task<IActionResult> Set(string key, SetSysConfigRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = currentUser.UserId ?? request.UserId;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Distribution.Features.User;
|
||||
|
||||
public record CreateUserRequest(
|
||||
[EmailAddress] string Username,
|
||||
string Username,
|
||||
string Password,
|
||||
string FullName,
|
||||
Guid RoleId,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Distribution.Features.Auth;
|
||||
using Distribution.Infra.UoW;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Distribution.Features.User;
|
||||
|
||||
public class UserService(IUserRepository repo, IUnitOfWork uow, IAuthHexClient authHex)
|
||||
public class UserService(IUserRepository repo, IUnitOfWork uow)
|
||||
{
|
||||
private readonly PasswordHasher<Models.User> _hasher = new();
|
||||
|
||||
private static UserResponse ToResponse(Models.User u) =>
|
||||
new(u.Id, u.Username, u.FullName, u.FK_RoleId, u.Role?.Name ?? string.Empty,
|
||||
u.FK_ReportsToUserId, u.IsActive, u.CreatedAt, u.UpdatedAt);
|
||||
@@ -31,30 +33,12 @@ public class UserService(IUserRepository repo, IUnitOfWork uow, IAuthHexClient a
|
||||
FK_RoleId = request.RoleId,
|
||||
FK_ReportsToUserId = request.ReportsToUserId
|
||||
};
|
||||
user.PasswordHash = _hasher.HashPassword(user, request.Password);
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try
|
||||
{
|
||||
await repo.AddAsync(user);
|
||||
|
||||
var authResult = await authHex.CallAsync("registerUser", new
|
||||
{
|
||||
userId = user.Id,
|
||||
userName = request.Username,
|
||||
email = request.Username,
|
||||
fullname = request.FullName,
|
||||
password = request.Password,
|
||||
roleId = request.RoleId,
|
||||
userTypeId = "00000001-0000-0000-0000-200000000000",
|
||||
sendCredentialsEmail = false
|
||||
}, reference: user.Id.ToString(), ct: ct);
|
||||
|
||||
if (!authResult.Success)
|
||||
{
|
||||
await uow.RollbackAsync(ct);
|
||||
throw new InvalidOperationException($"AuthHex registration failed: {authResult.Message}");
|
||||
}
|
||||
|
||||
await uow.CommitAsync(ct);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Distribution.Features.Vehicle;
|
||||
|
||||
public interface IVehicleDashboardRepository
|
||||
{
|
||||
Task<List<VehicleBalanceRow>> GetStockOnBoardAsync(Guid vehicleId);
|
||||
Task<List<VehicleMovementRow>> GetMovementsAsync(Guid vehicleId, DateTime from, DateTime toExclusive);
|
||||
|
||||
Task<List<VehicleRideRow>> GetRidesAsync(Guid vehicleId, DateTime from, DateTime toExclusive);
|
||||
Task<VehicleRideRow?> GetOpenRideAsync(Guid vehicleId);
|
||||
Task<List<VehicleTaskRow>> GetTasksAsync(Guid vehicleId, DateTime from, DateTime toExclusive);
|
||||
|
||||
Task<List<VehicleCollectionRow>> GetCollectionsAsync(Guid vehicleId, DateTime from, DateTime toExclusive);
|
||||
Task<VehicleReturnTotals> GetReturnTotalsAsync(Guid vehicleId, DateTime from, DateTime toExclusive);
|
||||
|
||||
Task<List<VehicleDriverRow>> GetDriversAsync(IEnumerable<Guid> driverProfileIds);
|
||||
Task<VehicleNamedRef?> GetWarehouseRefAsync(Guid? warehouseId);
|
||||
Task<VehicleNamedRef?> GetMobileWarehouseAsync(Guid vehicleId);
|
||||
|
||||
Task<Dictionary<Guid, string>> GetLocationNamesAsync(IEnumerable<Guid> ids);
|
||||
Task<Dictionary<Guid, string>> GetUserNamesAsync(IEnumerable<Guid> ids);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Distribution.Features.Vehicle;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/vehicles")]
|
||||
public class VehicleController(VehicleService service) : ControllerBase
|
||||
public class VehicleController(VehicleService service, VehicleDashboardService dashboardService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
@@ -17,6 +17,15 @@ public class VehicleController(VehicleService service) : ControllerBase
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/dashboard")]
|
||||
public async Task<IActionResult> Dashboard(Guid id, [FromQuery] DateTime? from, [FromQuery] DateTime? to)
|
||||
{
|
||||
var error = VehicleDashboardService.Validate(from, to);
|
||||
if (error is not null) return BadRequest(new { message = error });
|
||||
var result = await dashboardService.GetAsync(id, from, to);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateVehicleRequest request, CancellationToken ct)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Vehicle;
|
||||
|
||||
// ── Repository projections ─────────────────────────────────────────────────
|
||||
|
||||
public record VehicleBalanceRow(
|
||||
Guid ItemId, string Sku, string Name, string Category, string Uom,
|
||||
decimal? SalePrice, decimal Quantity, DateTime UpdatedAt);
|
||||
|
||||
public record VehicleMovementRow(
|
||||
Guid Id, Guid ItemId, string ItemName, string Sku,
|
||||
Guid? FromLocationId, LocationType? FromLocationType,
|
||||
Guid? ToLocationId, LocationType? ToLocationType,
|
||||
decimal Quantity, MovementType Type, string? ReasonCode, Guid? ReferenceId,
|
||||
DateTime CreatedAt, Guid CreatedBy);
|
||||
|
||||
public record VehicleRideRow(
|
||||
Guid Id, RideStatus Status, Guid DriverProfileId, string DriverName,
|
||||
int MeterStart, int MeterEnd, DateTime? StartedAt, DateTime? ClosedAt, DateTime CreatedAt,
|
||||
CancelRequestType? CancelType, string? CancelReason,
|
||||
int Tasks, int Delivered, int Failed);
|
||||
|
||||
public record VehicleTaskRow(
|
||||
Guid RideId, DeliveryTaskStatus Status, Guid StoreId, string StoreName,
|
||||
decimal DeliveredValue, DateTime Date);
|
||||
|
||||
public record VehicleCollectionRow(PaymentMethod Method, decimal Amount, int Count);
|
||||
|
||||
public record VehicleReturnTotals(int ReturnCount, decimal CreditValue, decimal Units);
|
||||
|
||||
public record VehicleDriverRow(
|
||||
Guid Id, string Name, string LicenseNumber, DateTime LicenseExpiry, DateTime MedicalClearanceExpiry, bool IsActive);
|
||||
|
||||
public record VehicleNamedRef(Guid Id, string Name);
|
||||
|
||||
// ── Response ───────────────────────────────────────────────────────────────
|
||||
|
||||
public record VehicleDashboardPeriod(DateTime From, DateTime To);
|
||||
|
||||
public record VehicleDashboardKpis(
|
||||
int Rides, int ClosedRides, int CancelledRides, decimal DistanceKm,
|
||||
int Deliveries, int DeliveredCount, int FailedCount, int PendingCount, decimal SuccessRatePercent,
|
||||
decimal DeliveredValue, decimal Collections,
|
||||
decimal StockOnBoardUnits, decimal StockOnBoardValue,
|
||||
decimal UnitsLoaded, decimal UnitsSold);
|
||||
|
||||
public record VehicleDashboardStockRow(
|
||||
Guid ItemId, string Sku, string Name, string Category, string Uom,
|
||||
decimal Quantity, decimal Value, DateTime UpdatedAt);
|
||||
|
||||
public record VehicleDashboardRide(
|
||||
Guid Id, RideStatus Status, string DriverName, DateTime? StartedAt, DateTime? ClosedAt, DateTime CreatedAt,
|
||||
decimal DistanceKm, int Tasks, int Delivered, int Failed, CancelRequestType? CancelType, string? CancelReason);
|
||||
|
||||
public record VehicleDashboardDailyDelivery(string Date, int Delivered, int Failed);
|
||||
|
||||
public record VehicleDashboardDailyMovement(string Date, decimal In, decimal Out);
|
||||
|
||||
public record VehicleDashboardMovementType(MovementType Type, string Direction, decimal Units, int Count);
|
||||
|
||||
public record VehicleDashboardLedgerRow(
|
||||
Guid Id, DateTime CreatedAt, Guid ItemId, string ItemName, string Sku,
|
||||
MovementType Type, string Direction, decimal Quantity,
|
||||
string FromName, string ToName, Guid? ReferenceId, string? ReferenceKind,
|
||||
string? ReasonCode, string CreatedByName);
|
||||
|
||||
public record VehicleDashboardCancelReason(CancelRequestType Type, int Count);
|
||||
|
||||
public record VehicleDashboardCollection(PaymentMethod Method, decimal Amount, int Count);
|
||||
|
||||
public record VehicleDashboardReturns(int ReturnCount, decimal CreditValue, decimal ReturnedUnits, decimal CustomerReturnUnitsOnVehicle);
|
||||
|
||||
public record VehicleDashboardTopStore(Guid StoreId, string StoreName, int Deliveries, decimal Value);
|
||||
|
||||
public record VehicleDashboardDriver(
|
||||
Guid Id, string Name, string LicenseNumber, DateTime LicenseExpiry, DateTime MedicalClearanceExpiry,
|
||||
bool IsActive, int Rides, decimal DistanceKm, DateTime? LastRideAt);
|
||||
|
||||
public record VehicleDashboardCurrentRide(
|
||||
Guid Id, string DriverName, DateTime? StartedAt, int MeterStart, int Tasks, int Delivered, int Failed);
|
||||
|
||||
public record VehicleDashboardResponse(
|
||||
VehicleResponse Vehicle,
|
||||
VehicleNamedRef? DefaultWarehouse,
|
||||
VehicleNamedRef? MobileWarehouse,
|
||||
VehicleDashboardCurrentRide? CurrentRide,
|
||||
VehicleDashboardPeriod Period,
|
||||
VehicleDashboardKpis Kpis,
|
||||
List<VehicleDashboardStockRow> StockOnBoard,
|
||||
List<VehicleDashboardRide> Rides,
|
||||
List<VehicleDashboardDailyDelivery> DailyDeliveries,
|
||||
List<VehicleDashboardDailyMovement> DailyMovement,
|
||||
List<VehicleDashboardMovementType> MovementByType,
|
||||
List<VehicleDashboardLedgerRow> Ledger,
|
||||
List<VehicleDashboardCancelReason> CancelReasons,
|
||||
List<VehicleDashboardCollection> CollectionsByMethod,
|
||||
VehicleDashboardReturns Returns,
|
||||
List<VehicleDashboardTopStore> TopStores,
|
||||
List<VehicleDashboardDriver> Drivers);
|
||||
@@ -0,0 +1,130 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.Vehicle;
|
||||
|
||||
public class VehicleDashboardRepository(AppDBContext db) : IVehicleDashboardRepository
|
||||
{
|
||||
public Task<List<VehicleBalanceRow>> GetStockOnBoardAsync(Guid vehicleId) =>
|
||||
db.StockBalances.AsNoTracking()
|
||||
.Where(b => b.LocationType == LocationType.Vehicle && b.LocationId == vehicleId && b.Quantity > 0)
|
||||
.Select(b => new VehicleBalanceRow(
|
||||
b.FK_ItemId, b.Item.Sku, b.Item.Name, b.Item.Category.Name, b.Item.BaseUom.Name,
|
||||
b.Item.SalePrice, b.Quantity, b.UpdatedAt))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<VehicleMovementRow>> GetMovementsAsync(Guid vehicleId, DateTime from, DateTime toExclusive) =>
|
||||
db.StockMovements.AsNoTracking()
|
||||
.Where(m => (m.FromLocationId == vehicleId || m.ToLocationId == vehicleId)
|
||||
&& m.CreatedAt >= from && m.CreatedAt < toExclusive)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.Select(m => new VehicleMovementRow(
|
||||
m.Id, m.FK_ItemId, m.Item.Name, m.Item.Sku,
|
||||
m.FromLocationId, m.FromLocationType, m.ToLocationId, m.ToLocationType,
|
||||
m.Quantity, m.Type, m.ReasonCode, m.ReferenceId, m.CreatedAt, m.CreatedBy))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<VehicleRideRow>> GetRidesAsync(Guid vehicleId, DateTime from, DateTime toExclusive) =>
|
||||
db.DeliveryRuns.AsNoTracking()
|
||||
.Where(r => r.FK_VehicleId == vehicleId
|
||||
&& (r.StartedAt ?? r.CreatedAt) >= from && (r.StartedAt ?? r.CreatedAt) < toExclusive)
|
||||
.OrderByDescending(r => r.StartedAt ?? r.CreatedAt)
|
||||
.Select(r => new VehicleRideRow(
|
||||
r.Id, r.Status, r.FK_DriverProfileId, r.DriverProfile.User.FullName,
|
||||
r.Meterstart, r.Meterend, r.StartedAt, r.ClosedAt, r.CreatedAt,
|
||||
r.CancelTypeCode, r.CancelReason,
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id),
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id
|
||||
&& (t.Status == DeliveryTaskStatus.Delivered || t.Status == DeliveryTaskStatus.PartiallyDelivered)),
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id && t.Status == DeliveryTaskStatus.Failed)))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<VehicleRideRow?> GetOpenRideAsync(Guid vehicleId) =>
|
||||
db.DeliveryRuns.AsNoTracking()
|
||||
.Where(r => r.FK_VehicleId == vehicleId && r.Status == RideStatus.Open)
|
||||
.Select(r => new VehicleRideRow(
|
||||
r.Id, r.Status, r.FK_DriverProfileId, r.DriverProfile.User.FullName,
|
||||
r.Meterstart, r.Meterend, r.StartedAt, r.ClosedAt, r.CreatedAt,
|
||||
r.CancelTypeCode, r.CancelReason,
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id),
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id
|
||||
&& (t.Status == DeliveryTaskStatus.Delivered || t.Status == DeliveryTaskStatus.PartiallyDelivered)),
|
||||
db.DeliveryTasks.Count(t => t.FK_RideId == r.Id && t.Status == DeliveryTaskStatus.Failed)))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public Task<List<VehicleTaskRow>> GetTasksAsync(Guid vehicleId, DateTime from, DateTime toExclusive) =>
|
||||
db.DeliveryTasks.AsNoTracking()
|
||||
.Where(t => t.Ride.FK_VehicleId == vehicleId
|
||||
&& (t.Ride.StartedAt ?? t.Ride.CreatedAt) >= from && (t.Ride.StartedAt ?? t.Ride.CreatedAt) < toExclusive)
|
||||
.Select(t => new VehicleTaskRow(
|
||||
t.FK_RideId, t.Status, t.ShopPO.FK_StoreId, t.ShopPO.Store.StoreName,
|
||||
t.ShopPO.Items.Sum(i => i.QuantityFulfilled * i.UnitPrice),
|
||||
t.Ride.StartedAt ?? t.Ride.CreatedAt))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<VehicleCollectionRow>> GetCollectionsAsync(Guid vehicleId, DateTime from, DateTime toExclusive) =>
|
||||
db.Payments.AsNoTracking()
|
||||
.Where(p => p.CollectedAt >= from && p.CollectedAt < toExclusive
|
||||
&& db.DeliveryTasks.Any(t => t.Ride.FK_VehicleId == vehicleId && t.FK_ShopPOId == p.Invoice.FK_ShopPOId))
|
||||
.GroupBy(p => p.Method)
|
||||
.Select(g => new VehicleCollectionRow(g.Key, g.Sum(p => p.Amount), g.Count()))
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<VehicleReturnTotals> GetReturnTotalsAsync(Guid vehicleId, DateTime from, DateTime toExclusive)
|
||||
{
|
||||
var returns = db.SaleReturns.AsNoTracking()
|
||||
.Where(r => r.CreatedAt >= from && r.CreatedAt < toExclusive
|
||||
&& db.DeliveryTasks.Any(t => t.Ride.FK_VehicleId == vehicleId && t.FK_ShopPOId == r.FK_ShopPOId));
|
||||
var count = await returns.CountAsync();
|
||||
var credit = await returns.SumAsync(r => (decimal?)r.TotalCreditAmount) ?? 0m;
|
||||
var units = await returns.SelectMany(r => r.Items).SumAsync(i => (decimal?)i.Quantity) ?? 0m;
|
||||
return new VehicleReturnTotals(count, credit, units);
|
||||
}
|
||||
|
||||
public Task<List<VehicleDriverRow>> GetDriversAsync(IEnumerable<Guid> driverProfileIds)
|
||||
{
|
||||
var ids = driverProfileIds.Distinct().ToList();
|
||||
return db.DriverProfiles.AsNoTracking()
|
||||
.Where(d => ids.Contains(d.Id))
|
||||
.Select(d => new VehicleDriverRow(
|
||||
d.Id, d.User.FullName, d.LicenseNumber, d.LicenseExpiry, d.MedicalClearanceExpiry, d.IsActive))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public Task<VehicleNamedRef?> GetWarehouseRefAsync(Guid? warehouseId) =>
|
||||
warehouseId is null
|
||||
? Task.FromResult<VehicleNamedRef?>(null)
|
||||
: db.Warehouses.AsNoTracking()
|
||||
.Where(w => w.Id == warehouseId)
|
||||
.Select(w => new VehicleNamedRef(w.Id, w.Name))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public Task<VehicleNamedRef?> GetMobileWarehouseAsync(Guid vehicleId) =>
|
||||
db.Warehouses.AsNoTracking()
|
||||
.Where(w => w.VehicleId == vehicleId)
|
||||
.Select(w => new VehicleNamedRef(w.Id, w.Name))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<Dictionary<Guid, string>> GetLocationNamesAsync(IEnumerable<Guid> ids)
|
||||
{
|
||||
var idList = ids.Distinct().ToList();
|
||||
var names = new Dictionary<Guid, string>();
|
||||
if (idList.Count == 0) return names;
|
||||
|
||||
foreach (var w in await db.Warehouses.AsNoTracking().Where(w => idList.Contains(w.Id)).Select(w => new { w.Id, w.Name }).ToListAsync())
|
||||
names[w.Id] = w.Name;
|
||||
foreach (var v in await db.Vehicles.AsNoTracking().Where(v => idList.Contains(v.Id)).Select(v => new { v.Id, v.RegNumber }).ToListAsync())
|
||||
names[v.Id] = v.RegNumber;
|
||||
return names;
|
||||
}
|
||||
|
||||
public async Task<Dictionary<Guid, string>> GetUserNamesAsync(IEnumerable<Guid> ids)
|
||||
{
|
||||
var idList = ids.Distinct().ToList();
|
||||
if (idList.Count == 0) return [];
|
||||
return await db.Users.AsNoTracking()
|
||||
.Where(u => idList.Contains(u.Id))
|
||||
.ToDictionaryAsync(u => u.Id, u => u.FullName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Vehicle;
|
||||
|
||||
public class VehicleDashboardService(IVehicleRepository vehicleRepo, IVehicleDashboardRepository repo)
|
||||
{
|
||||
private const int LedgerSize = 50;
|
||||
private const int RideListSize = 15;
|
||||
private const int TopListSize = 5;
|
||||
private const int MaxPeriodDays = 366;
|
||||
|
||||
public static string? Validate(DateTime? from, DateTime? to)
|
||||
{
|
||||
if (from.HasValue && to.HasValue)
|
||||
{
|
||||
if (from.Value.Date > to.Value.Date) return "'from' must not be after 'to'.";
|
||||
if ((to.Value.Date - from.Value.Date).TotalDays >= MaxPeriodDays) return $"The period cannot exceed {MaxPeriodDays} days.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Unlike the standard vehicle lookup, this also serves inactive vehicles so their history stays viewable.</summary>
|
||||
public async Task<VehicleDashboardResponse?> GetAsync(Guid id, DateTime? from, DateTime? to)
|
||||
{
|
||||
var vehicle = await vehicleRepo.GetByIdAsync(id);
|
||||
if (vehicle is null) return null;
|
||||
|
||||
var toDate = (to ?? DateTime.Now).Date;
|
||||
var fromDate = (from ?? toDate.AddDays(-29)).Date;
|
||||
var toExclusive = toDate.AddDays(1);
|
||||
|
||||
var balances = await repo.GetStockOnBoardAsync(id);
|
||||
var movements = (await repo.GetMovementsAsync(id, fromDate, toExclusive))
|
||||
.Select(m => (Row: m, Direction: DirectionOf(m, id)))
|
||||
.Where(x => x.Direction is not null)
|
||||
.ToList();
|
||||
var rides = await repo.GetRidesAsync(id, fromDate, toExclusive);
|
||||
var tasks = await repo.GetTasksAsync(id, fromDate, toExclusive);
|
||||
var collections = await repo.GetCollectionsAsync(id, fromDate, toExclusive);
|
||||
var returnTotals = await repo.GetReturnTotalsAsync(id, fromDate, toExclusive);
|
||||
var openRide = await repo.GetOpenRideAsync(id);
|
||||
|
||||
// ── Stock on board ─────────────────────────────────────────────────
|
||||
var stock = balances
|
||||
.GroupBy(b => b.ItemId)
|
||||
.Select(g =>
|
||||
{
|
||||
var f = g.First();
|
||||
var qty = g.Sum(x => x.Quantity);
|
||||
return new VehicleDashboardStockRow(
|
||||
f.ItemId, f.Sku, f.Name, f.Category, f.Uom, qty, qty * (f.SalePrice ?? 0m), g.Max(x => x.UpdatedAt));
|
||||
})
|
||||
.OrderBy(r => r.Name)
|
||||
.ToList();
|
||||
|
||||
// ── Rides and deliveries ───────────────────────────────────────────
|
||||
static decimal Km(VehicleRideRow r) =>
|
||||
r.Status == RideStatus.Closed && r.MeterEnd > r.MeterStart ? r.MeterEnd - r.MeterStart : 0m;
|
||||
|
||||
var rideRows = rides.Take(RideListSize)
|
||||
.Select(r => new VehicleDashboardRide(
|
||||
r.Id, r.Status, r.DriverName, r.StartedAt, r.ClosedAt, r.CreatedAt,
|
||||
Km(r), r.Tasks, r.Delivered, r.Failed, r.CancelType, r.CancelReason))
|
||||
.ToList();
|
||||
|
||||
bool IsDelivered(VehicleTaskRow t) =>
|
||||
t.Status is DeliveryTaskStatus.Delivered or DeliveryTaskStatus.PartiallyDelivered;
|
||||
var delivered = tasks.Count(IsDelivered);
|
||||
var failed = tasks.Count(t => t.Status == DeliveryTaskStatus.Failed);
|
||||
var pending = tasks.Count(t => t.Status == DeliveryTaskStatus.Pending);
|
||||
var deliveredValue = tasks.Where(IsDelivered).Sum(t => t.DeliveredValue);
|
||||
|
||||
var dailyDeliveries = new List<VehicleDashboardDailyDelivery>();
|
||||
var dailyMovement = new List<VehicleDashboardDailyMovement>();
|
||||
var tasksByDay = tasks.GroupBy(t => t.Date.Date).ToDictionary(g => g.Key);
|
||||
var movesByDay = movements.GroupBy(x => x.Row.CreatedAt.Date).ToDictionary(g => g.Key);
|
||||
for (var d = fromDate; d <= toDate; d = d.AddDays(1))
|
||||
{
|
||||
var key = d.ToString("yyyy-MM-dd");
|
||||
tasksByDay.TryGetValue(d, out var dayTasks);
|
||||
movesByDay.TryGetValue(d, out var dayMoves);
|
||||
dailyDeliveries.Add(new VehicleDashboardDailyDelivery(
|
||||
key, dayTasks?.Count(IsDelivered) ?? 0, dayTasks?.Count(t => t.Status == DeliveryTaskStatus.Failed) ?? 0));
|
||||
dailyMovement.Add(new VehicleDashboardDailyMovement(
|
||||
key,
|
||||
dayMoves?.Where(x => x.Direction == "In").Sum(x => x.Row.Quantity) ?? 0m,
|
||||
dayMoves?.Where(x => x.Direction == "Out").Sum(x => x.Row.Quantity) ?? 0m));
|
||||
}
|
||||
|
||||
var cancelReasons = rides
|
||||
.Where(r => r.Status == RideStatus.Cancelled && r.CancelType.HasValue)
|
||||
.GroupBy(r => r.CancelType!.Value)
|
||||
.Select(g => new VehicleDashboardCancelReason(g.Key, g.Count()))
|
||||
.OrderByDescending(c => c.Count)
|
||||
.ToList();
|
||||
|
||||
var topStores = tasks
|
||||
.Where(IsDelivered)
|
||||
.GroupBy(t => (t.StoreId, t.StoreName))
|
||||
.Select(g => new VehicleDashboardTopStore(g.Key.StoreId, g.Key.StoreName, g.Count(), g.Sum(t => t.DeliveredValue)))
|
||||
.OrderByDescending(s => s.Value)
|
||||
.Take(TopListSize)
|
||||
.ToList();
|
||||
|
||||
// ── Movements ──────────────────────────────────────────────────────
|
||||
var byType = movements
|
||||
.GroupBy(x => (x.Row.Type, x.Direction))
|
||||
.Select(g => new VehicleDashboardMovementType(g.Key.Type, g.Key.Direction!, g.Sum(x => x.Row.Quantity), g.Count()))
|
||||
.OrderByDescending(r => r.Units)
|
||||
.ToList();
|
||||
|
||||
var ledgerSource = movements.Take(LedgerSize).ToList();
|
||||
var locationIds = ledgerSource
|
||||
.SelectMany(x => new[]
|
||||
{
|
||||
(x.Row.FromLocationId, x.Row.FromLocationType),
|
||||
(x.Row.ToLocationId, x.Row.ToLocationType),
|
||||
})
|
||||
.Where(l => l.Item1.HasValue && l.Item2 is LocationType t && t != LocationType.External)
|
||||
.Select(l => l.Item1!.Value);
|
||||
var locationNames = await repo.GetLocationNamesAsync(locationIds);
|
||||
var userNames = await repo.GetUserNamesAsync(ledgerSource.Select(x => x.Row.CreatedBy));
|
||||
|
||||
var ledger = ledgerSource.Select(x => new VehicleDashboardLedgerRow(
|
||||
x.Row.Id, x.Row.CreatedAt, x.Row.ItemId, x.Row.ItemName, x.Row.Sku,
|
||||
x.Row.Type, x.Direction!, x.Row.Quantity,
|
||||
SideName(x.Row.Type, x.Row.FromLocationId, x.Row.FromLocationType, locationNames, isFrom: true),
|
||||
SideName(x.Row.Type, x.Row.ToLocationId, x.Row.ToLocationType, locationNames, isFrom: false),
|
||||
x.Row.ReferenceId, ReferenceKind(x.Row.Type),
|
||||
x.Row.ReasonCode, userNames.GetValueOrDefault(x.Row.CreatedBy, "—"))).ToList();
|
||||
|
||||
// ── Drivers ────────────────────────────────────────────────────────
|
||||
var driverProfiles = (await repo.GetDriversAsync(rides.Select(r => r.DriverProfileId)))
|
||||
.ToDictionary(d => d.Id);
|
||||
var drivers = rides
|
||||
.GroupBy(r => r.DriverProfileId)
|
||||
.Where(g => driverProfiles.ContainsKey(g.Key))
|
||||
.Select(g =>
|
||||
{
|
||||
var d = driverProfiles[g.Key];
|
||||
return new VehicleDashboardDriver(
|
||||
d.Id, d.Name, d.LicenseNumber, d.LicenseExpiry, d.MedicalClearanceExpiry, d.IsActive,
|
||||
g.Count(), g.Sum(Km), g.Max(r => r.StartedAt ?? r.CreatedAt));
|
||||
})
|
||||
.OrderByDescending(d => d.Rides)
|
||||
.ToList();
|
||||
|
||||
// ── Assemble ───────────────────────────────────────────────────────
|
||||
var settled = delivered + failed;
|
||||
var kpis = new VehicleDashboardKpis(
|
||||
rides.Count, rides.Count(r => r.Status == RideStatus.Closed), rides.Count(r => r.Status == RideStatus.Cancelled),
|
||||
rides.Sum(Km),
|
||||
tasks.Count, delivered, failed, pending,
|
||||
settled == 0 ? 0m : Math.Round(delivered * 100m / settled, 1),
|
||||
deliveredValue, collections.Sum(c => c.Amount),
|
||||
stock.Sum(r => r.Quantity), stock.Sum(r => r.Value),
|
||||
movements.Where(x => x.Row.Type == MovementType.Load && x.Direction == "In").Sum(x => x.Row.Quantity),
|
||||
movements.Where(x => x.Row.Type == MovementType.Sale && x.Direction == "Out").Sum(x => x.Row.Quantity));
|
||||
|
||||
var customerReturnUnits = movements
|
||||
.Where(x => x.Row.Type == MovementType.CustomerReturn && x.Direction == "In")
|
||||
.Sum(x => x.Row.Quantity);
|
||||
|
||||
return new VehicleDashboardResponse(
|
||||
new VehicleResponse(vehicle.Id, vehicle.RegNumber, vehicle.NumberPlate, vehicle.Type, vehicle.IsActive, vehicle.CreatedAt),
|
||||
await repo.GetWarehouseRefAsync(vehicle.DefaultWarehouseId),
|
||||
await repo.GetMobileWarehouseAsync(id),
|
||||
openRide is null ? null : new VehicleDashboardCurrentRide(
|
||||
openRide.Id, openRide.DriverName, openRide.StartedAt, openRide.MeterStart,
|
||||
openRide.Tasks, openRide.Delivered, openRide.Failed),
|
||||
new VehicleDashboardPeriod(fromDate, toDate),
|
||||
kpis, stock, rideRows, dailyDeliveries, dailyMovement, byType, ledger, cancelReasons,
|
||||
collections.Select(c => new VehicleDashboardCollection(c.Method, c.Amount, c.Count))
|
||||
.OrderByDescending(c => c.Amount).ToList(),
|
||||
new VehicleDashboardReturns(returnTotals.ReturnCount, returnTotals.CreditValue, returnTotals.Units, customerReturnUnits),
|
||||
topStores, drivers);
|
||||
}
|
||||
|
||||
private static string? DirectionOf(VehicleMovementRow m, Guid vehicleId) =>
|
||||
m.ToLocationId == vehicleId && m.FromLocationId != vehicleId ? "In"
|
||||
: m.FromLocationId == vehicleId && m.ToLocationId != vehicleId ? "Out"
|
||||
: null;
|
||||
|
||||
private static string? ReferenceKind(MovementType type) => type switch
|
||||
{
|
||||
MovementType.Load => "Loading Sheet",
|
||||
MovementType.Sale => "Order",
|
||||
MovementType.CustomerReturn => "Return",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
private static string SideName(
|
||||
MovementType type, Guid? id, LocationType? locationType, Dictionary<Guid, string> names, bool isFrom)
|
||||
{
|
||||
if (id is not Guid locId || locationType is not LocationType lt) return "—";
|
||||
if (lt != LocationType.External) return names.GetValueOrDefault(locId, "—");
|
||||
return type switch
|
||||
{
|
||||
MovementType.Sale or MovementType.CustomerReturn => "Customer",
|
||||
MovementType.PurchaseReceipt or MovementType.PurchaseReturn => "Supplier",
|
||||
MovementType.Damage => "Written Off",
|
||||
MovementType.Adjustment => "Stock Adjustment",
|
||||
_ => isFrom ? "External Source" : "External Destination",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Distribution.Features.Warehouse;
|
||||
|
||||
public interface IWarehouseDashboardRepository
|
||||
{
|
||||
Task<List<WarehouseBalanceRow>> GetBalanceRowsAsync(Guid warehouseId);
|
||||
Task<List<WarehouseMovementRow>> GetMovementsAsync(Guid warehouseId, DateTime from, DateTime toExclusive);
|
||||
Task<List<WarehouseLastOutboundRow>> GetLastOutboundAsync(Guid warehouseId);
|
||||
|
||||
Task<WarehouseGrnTotals> GetGrnTotalsAsync(Guid warehouseId, DateTime from, DateTime toExclusive);
|
||||
Task<List<DashboardGrnRow>> GetRecentGrnsAsync(Guid warehouseId, DateTime from, DateTime toExclusive, int take);
|
||||
|
||||
Task<List<DashboardLoadingSheetRow>> GetRecentLoadingSheetsAsync(Guid warehouseId, DateTime from, DateTime toExclusive, int take);
|
||||
Task<decimal> GetPendingDispatchUnitsAsync(Guid warehouseId);
|
||||
|
||||
Task<List<WarehouseVehicleStockRow>> GetVehicleStockAsync(Guid warehouseId, Guid? primaryVehicleId);
|
||||
Task<List<DashboardLinkedVehicle>> GetDefaultVehiclesAsync(Guid warehouseId, Guid? primaryVehicleId);
|
||||
|
||||
Task<int> GetOpenClaimCountAsync(Guid warehouseId);
|
||||
Task<List<DashboardClaimRow>> GetOpenClaimsAsync(Guid warehouseId, int take);
|
||||
|
||||
Task<Dictionary<Guid, string>> GetLocationNamesAsync(IEnumerable<Guid> ids);
|
||||
Task<Dictionary<Guid, string>> GetUserNamesAsync(IEnumerable<Guid> ids);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Distribution.Features.Warehouse;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/warehouses")]
|
||||
public class WarehouseController(WarehouseService service) : ControllerBase
|
||||
public class WarehouseController(WarehouseService service, WarehouseDashboardService dashboardService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
@@ -17,6 +17,16 @@ public class WarehouseController(WarehouseService service) : ControllerBase
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:guid}/dashboard")]
|
||||
public async Task<IActionResult> Dashboard(
|
||||
Guid id, [FromQuery] DateTime? from, [FromQuery] DateTime? to, [FromQuery] int deadStockDays = 30)
|
||||
{
|
||||
var error = WarehouseDashboardService.Validate(from, to, deadStockDays);
|
||||
if (error is not null) return BadRequest(new { message = error });
|
||||
var result = await dashboardService.GetAsync(id, from, to, deadStockDays);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateWarehouseRequest request, CancellationToken ct)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Warehouse;
|
||||
|
||||
// ── Repository projections ─────────────────────────────────────────────────
|
||||
|
||||
public record WarehouseBalanceRow(
|
||||
Guid ItemId, string Sku, string Name, string Category, string? Brand, string Uom,
|
||||
decimal? ReorderLevel, decimal? CostPrice, decimal? SalePrice,
|
||||
Guid? BatchId, string? BatchNumber, DateTime? ExpiryDate,
|
||||
decimal Quantity, DateTime UpdatedAt);
|
||||
|
||||
public record WarehouseMovementRow(
|
||||
Guid Id, Guid ItemId, string ItemName, string Sku,
|
||||
Guid? FromLocationId, LocationType? FromLocationType,
|
||||
Guid? ToLocationId, LocationType? ToLocationType,
|
||||
decimal Quantity, MovementType Type, string? ReasonCode, Guid? ReferenceId,
|
||||
DateTime CreatedAt, Guid CreatedBy);
|
||||
|
||||
public record WarehouseLastOutboundRow(Guid ItemId, DateTime LastOutboundAt);
|
||||
|
||||
public record WarehouseGrnTotals(int Count, int Accepted, int Rejected);
|
||||
|
||||
public record WarehouseVehicleStockRow(
|
||||
Guid VehicleId, string RegNumber, string NumberPlate, bool IsLinked, decimal Units, int Skus);
|
||||
|
||||
// ── Response ───────────────────────────────────────────────────────────────
|
||||
|
||||
public record DashboardPeriod(DateTime From, DateTime To);
|
||||
|
||||
public record DashboardKpis(
|
||||
decimal StockValueCost, decimal StockValueSale, decimal TotalUnits, int SkuCount,
|
||||
int LowStockCount, int OutOfStockCount, int NearExpiryCount, int ExpiredCount,
|
||||
decimal UnitsIn, decimal UnitsOut);
|
||||
|
||||
public record DashboardBatch(Guid BatchId, string? BatchNumber, DateTime? ExpiryDate, decimal Quantity);
|
||||
|
||||
public record DashboardStockRow(
|
||||
Guid ItemId, string Sku, string Name, string Category, string? Brand, string Uom,
|
||||
decimal Quantity, decimal? ReorderLevel, string Status,
|
||||
decimal CostValue, decimal SaleValue, DateTime UpdatedAt, List<DashboardBatch> Batches);
|
||||
|
||||
public record DashboardCategoryStock(string Category, decimal Units, decimal Value);
|
||||
|
||||
public record DashboardExpiringBatch(
|
||||
Guid ItemId, string ItemName, string? BatchNumber, DateTime ExpiryDate, decimal Quantity, string Status);
|
||||
|
||||
public record DashboardDailyPoint(string Date, decimal In, decimal Out);
|
||||
|
||||
public record DashboardMovementTypeRow(MovementType Type, string Direction, decimal Units, int Count);
|
||||
|
||||
public record DashboardLedgerRow(
|
||||
Guid Id, DateTime CreatedAt, Guid ItemId, string ItemName, string Sku,
|
||||
MovementType Type, string Direction, decimal Quantity,
|
||||
string FromName, string ToName, Guid? ReferenceId, string? ReferenceKind,
|
||||
string? ReasonCode, string CreatedByName);
|
||||
|
||||
public record DashboardGrnRow(
|
||||
Guid Id, DateTime ReceivedAt, Guid? PurchaseOrderId, string? SupplierName,
|
||||
int AcceptedQuantity, int RejectedQuantity, decimal CostValue);
|
||||
|
||||
public record DashboardInbound(
|
||||
int GrnCount, int AcceptedUnits, int RejectedUnits, decimal RejectionRatePercent, List<DashboardGrnRow> RecentGrns);
|
||||
|
||||
public record DashboardLoadingSheetRow(
|
||||
Guid Id, Guid RideId, string VehiclePlate, LoadingSheetStatus Status,
|
||||
DateTime PopulatedAt, DateTime? ConfirmedAt, int Lines, decimal Units);
|
||||
|
||||
public record DashboardOutbound(
|
||||
decimal UnitsDispatched, decimal PendingDispatchUnits, List<DashboardLoadingSheetRow> RecentLoadingSheets);
|
||||
|
||||
public record DashboardVehicle(
|
||||
Guid VehicleId, string RegNumber, string NumberPlate, bool IsLinked, decimal Units, int Skus);
|
||||
|
||||
public record DashboardClaimRow(Guid Id, DateTime CreatedAt, string? SupplierName, string Details, decimal Units);
|
||||
|
||||
public record DashboardLosses(
|
||||
decimal PurchaseReturnUnits, decimal DamageUnits, decimal NegativeAdjustmentUnits,
|
||||
decimal PositiveAdjustmentUnits, int OpenClaimCount, List<DashboardClaimRow> OpenClaims);
|
||||
|
||||
public record DashboardTopMover(Guid ItemId, string Sku, string Name, decimal UnitsOut);
|
||||
|
||||
public record DashboardDeadStock(
|
||||
Guid ItemId, string Sku, string Name, decimal Quantity, decimal CostValue, DateTime? LastOutboundAt);
|
||||
|
||||
public record DashboardLinkedVehicle(Guid Id, string RegNumber, string NumberPlate, bool IsPrimary);
|
||||
|
||||
public record WarehouseDashboardResponse(
|
||||
WarehouseResponse Warehouse,
|
||||
List<DashboardLinkedVehicle> LinkedVehicles,
|
||||
DashboardPeriod Period,
|
||||
int DeadStockDays,
|
||||
DashboardKpis Kpis,
|
||||
List<DashboardStockRow> Stock,
|
||||
List<DashboardCategoryStock> StockByCategory,
|
||||
List<DashboardExpiringBatch> ExpiringBatches,
|
||||
List<DashboardDailyPoint> DailyMovement,
|
||||
List<DashboardMovementTypeRow> MovementByType,
|
||||
List<DashboardLedgerRow> Ledger,
|
||||
DashboardInbound Inbound,
|
||||
DashboardOutbound Outbound,
|
||||
List<DashboardVehicle> Vehicles,
|
||||
DashboardLosses Losses,
|
||||
List<DashboardTopMover> TopMovers,
|
||||
List<DashboardDeadStock> DeadStock);
|
||||
@@ -0,0 +1,160 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.Warehouse;
|
||||
|
||||
public class WarehouseDashboardRepository(AppDBContext db) : IWarehouseDashboardRepository
|
||||
{
|
||||
public Task<List<WarehouseBalanceRow>> GetBalanceRowsAsync(Guid warehouseId) =>
|
||||
db.StockBalances.AsNoTracking()
|
||||
.Where(b => b.LocationType == LocationType.Warehouse && b.LocationId == warehouseId)
|
||||
.Select(b => new WarehouseBalanceRow(
|
||||
b.FK_ItemId, b.Item.Sku, b.Item.Name, b.Item.Category.Name,
|
||||
b.Item.Brand != null ? b.Item.Brand.Name : null, b.Item.BaseUom.Name,
|
||||
b.Item.ReorderLevel, b.Item.CostPrice, b.Item.SalePrice,
|
||||
b.FK_ItemBatchId,
|
||||
b.ItemBatch != null ? b.ItemBatch.BatchNumber : null,
|
||||
b.ItemBatch != null ? b.ItemBatch.ExpiryDate : null,
|
||||
b.Quantity, b.UpdatedAt))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<WarehouseMovementRow>> GetMovementsAsync(Guid warehouseId, DateTime from, DateTime toExclusive) =>
|
||||
db.StockMovements.AsNoTracking()
|
||||
.Where(m => (m.FromLocationId == warehouseId || m.ToLocationId == warehouseId)
|
||||
&& m.CreatedAt >= from && m.CreatedAt < toExclusive)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.Select(m => new WarehouseMovementRow(
|
||||
m.Id, m.FK_ItemId, m.Item.Name, m.Item.Sku,
|
||||
m.FromLocationId, m.FromLocationType, m.ToLocationId, m.ToLocationType,
|
||||
m.Quantity, m.Type, m.ReasonCode, m.ReferenceId, m.CreatedAt, m.CreatedBy))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<WarehouseLastOutboundRow>> GetLastOutboundAsync(Guid warehouseId) =>
|
||||
db.StockMovements.AsNoTracking()
|
||||
.Where(m => m.FromLocationId == warehouseId && m.ToLocationId != warehouseId)
|
||||
.GroupBy(m => m.FK_ItemId)
|
||||
.Select(g => new WarehouseLastOutboundRow(g.Key, g.Max(x => x.CreatedAt)))
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<WarehouseGrnTotals> GetGrnTotalsAsync(Guid warehouseId, DateTime from, DateTime toExclusive)
|
||||
{
|
||||
var receipts = db.GoodsReceipts.AsNoTracking()
|
||||
.Where(g => g.FK_WarehouseId == warehouseId && g.ReceivedAt >= from && g.ReceivedAt < toExclusive);
|
||||
var count = await receipts.CountAsync();
|
||||
var accepted = await receipts.SelectMany(g => g.Items).SumAsync(i => (int?)i.AcceptedQuantity) ?? 0;
|
||||
var rejected = await receipts.SelectMany(g => g.Items).SumAsync(i => (int?)i.RejectedQuantity) ?? 0;
|
||||
return new WarehouseGrnTotals(count, accepted, rejected);
|
||||
}
|
||||
|
||||
public Task<List<DashboardGrnRow>> GetRecentGrnsAsync(Guid warehouseId, DateTime from, DateTime toExclusive, int take) =>
|
||||
db.GoodsReceipts.AsNoTracking()
|
||||
.Where(g => g.FK_WarehouseId == warehouseId && g.ReceivedAt >= from && g.ReceivedAt < toExclusive)
|
||||
.OrderByDescending(g => g.ReceivedAt)
|
||||
.Take(take)
|
||||
.Select(g => new DashboardGrnRow(
|
||||
g.Id, g.ReceivedAt, g.FK_PurchaseOrderId,
|
||||
g.PurchaseOrder != null ? g.PurchaseOrder.Supplier.Name : (g.Supplier != null ? g.Supplier.Name : null),
|
||||
g.Items.Sum(i => i.AcceptedQuantity),
|
||||
g.Items.Sum(i => i.RejectedQuantity),
|
||||
g.Items.Sum(i => i.AcceptedQuantity * i.UnitCost)))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<DashboardLoadingSheetRow>> GetRecentLoadingSheetsAsync(Guid warehouseId, DateTime from, DateTime toExclusive, int take) =>
|
||||
db.LoadingSheets.AsNoTracking()
|
||||
.Where(s => s.PopulatedAt >= from && s.PopulatedAt < toExclusive
|
||||
&& s.Items.Any(i => i.FK_WarehouseId == warehouseId))
|
||||
.OrderByDescending(s => s.PopulatedAt)
|
||||
.Take(take)
|
||||
.Select(s => new DashboardLoadingSheetRow(
|
||||
s.Id, s.FK_RideId, s.Ride.Vehicle.NumberPlate, s.Status, s.PopulatedAt, s.ConfirmedAt,
|
||||
s.Items.Count(i => i.FK_WarehouseId == warehouseId),
|
||||
s.Items.Where(i => i.FK_WarehouseId == warehouseId).Sum(i => i.QuantityDispatched)))
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<decimal> GetPendingDispatchUnitsAsync(Guid warehouseId) =>
|
||||
await db.LoadingSheetItems.AsNoTracking()
|
||||
.Where(i => i.FK_WarehouseId == warehouseId && i.LoadingSheet.Status == LoadingSheetStatus.Planned)
|
||||
.SumAsync(i => (decimal?)i.QuantityDispatched) ?? 0m;
|
||||
|
||||
public async Task<List<WarehouseVehicleStockRow>> GetVehicleStockAsync(Guid warehouseId, Guid? primaryVehicleId)
|
||||
{
|
||||
var loadedFromHere = db.LoadingSheetItems
|
||||
.Where(i => i.FK_WarehouseId == warehouseId)
|
||||
.Select(i => i.LoadingSheet.Ride.FK_VehicleId);
|
||||
|
||||
var vehicles = await db.Vehicles.AsNoTracking()
|
||||
.Where(v => v.IsActive
|
||||
&& (v.DefaultWarehouseId == warehouseId
|
||||
|| (primaryVehicleId != null && v.Id == primaryVehicleId)
|
||||
|| loadedFromHere.Contains(v.Id)))
|
||||
.Select(v => new
|
||||
{
|
||||
v.Id, v.RegNumber, v.NumberPlate,
|
||||
IsLinked = v.DefaultWarehouseId == warehouseId || (primaryVehicleId != null && v.Id == primaryVehicleId),
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var ids = vehicles.Select(v => v.Id).ToList();
|
||||
var balances = await db.StockBalances.AsNoTracking()
|
||||
.Where(b => b.LocationType == LocationType.Vehicle && ids.Contains(b.LocationId) && b.Quantity > 0)
|
||||
.GroupBy(b => b.LocationId)
|
||||
.Select(g => new { VehicleId = g.Key, Units = g.Sum(x => x.Quantity), Skus = g.Select(x => x.FK_ItemId).Distinct().Count() })
|
||||
.ToListAsync();
|
||||
|
||||
return vehicles
|
||||
.Select(v =>
|
||||
{
|
||||
var bal = balances.FirstOrDefault(b => b.VehicleId == v.Id);
|
||||
return new WarehouseVehicleStockRow(v.Id, v.RegNumber, v.NumberPlate, v.IsLinked, bal?.Units ?? 0m, bal?.Skus ?? 0);
|
||||
})
|
||||
.OrderByDescending(v => v.Units)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Task<List<DashboardLinkedVehicle>> GetDefaultVehiclesAsync(Guid warehouseId, Guid? primaryVehicleId) =>
|
||||
db.Vehicles.AsNoTracking()
|
||||
.Where(v => v.IsActive
|
||||
&& (v.DefaultWarehouseId == warehouseId || (primaryVehicleId != null && v.Id == primaryVehicleId)))
|
||||
.Select(v => new DashboardLinkedVehicle(
|
||||
v.Id, v.RegNumber, v.NumberPlate, primaryVehicleId != null && v.Id == primaryVehicleId))
|
||||
.ToListAsync();
|
||||
|
||||
public Task<int> GetOpenClaimCountAsync(Guid warehouseId) =>
|
||||
db.SupplierClaims.AsNoTracking()
|
||||
.CountAsync(c => c.Status == SupplierClaimStatus.Open
|
||||
&& c.GoodsReceipt != null && c.GoodsReceipt.FK_WarehouseId == warehouseId);
|
||||
|
||||
public Task<List<DashboardClaimRow>> GetOpenClaimsAsync(Guid warehouseId, int take) =>
|
||||
db.SupplierClaims.AsNoTracking()
|
||||
.Where(c => c.Status == SupplierClaimStatus.Open
|
||||
&& c.GoodsReceipt != null && c.GoodsReceipt.FK_WarehouseId == warehouseId)
|
||||
.OrderByDescending(c => c.CreatedAt)
|
||||
.Take(take)
|
||||
.Select(c => new DashboardClaimRow(
|
||||
c.Id, c.CreatedAt, c.PurchaseOrder.Supplier.Name, c.Details,
|
||||
c.Items.Sum(i => i.Quantity)))
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<Dictionary<Guid, string>> GetLocationNamesAsync(IEnumerable<Guid> ids)
|
||||
{
|
||||
var idList = ids.Distinct().ToList();
|
||||
var names = new Dictionary<Guid, string>();
|
||||
if (idList.Count == 0) return names;
|
||||
|
||||
foreach (var w in await db.Warehouses.AsNoTracking().Where(w => idList.Contains(w.Id)).Select(w => new { w.Id, w.Name }).ToListAsync())
|
||||
names[w.Id] = w.Name;
|
||||
foreach (var v in await db.Vehicles.AsNoTracking().Where(v => idList.Contains(v.Id)).Select(v => new { v.Id, v.RegNumber }).ToListAsync())
|
||||
names[v.Id] = v.RegNumber;
|
||||
return names;
|
||||
}
|
||||
|
||||
public async Task<Dictionary<Guid, string>> GetUserNamesAsync(IEnumerable<Guid> ids)
|
||||
{
|
||||
var idList = ids.Distinct().ToList();
|
||||
if (idList.Count == 0) return [];
|
||||
return await db.Users.AsNoTracking()
|
||||
.Where(u => idList.Contains(u.Id))
|
||||
.ToDictionaryAsync(u => u.Id, u => u.FullName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Warehouse;
|
||||
|
||||
public class WarehouseDashboardService(IWarehouseRepository warehouseRepo, IWarehouseDashboardRepository repo)
|
||||
{
|
||||
private const int NearExpiryDays = 30;
|
||||
private const int LedgerSize = 50;
|
||||
private const int RecentDocumentCount = 8;
|
||||
private const int TopListSize = 5;
|
||||
private const int DeadStockListSize = 10;
|
||||
private const int MaxPeriodDays = 366;
|
||||
|
||||
public static string? Validate(DateTime? from, DateTime? to, int deadStockDays)
|
||||
{
|
||||
if (deadStockDays < 1 || deadStockDays > 365) return "deadStockDays must be between 1 and 365.";
|
||||
if (from.HasValue && to.HasValue)
|
||||
{
|
||||
if (from.Value.Date > to.Value.Date) return "'from' must not be after 'to'.";
|
||||
if ((to.Value.Date - from.Value.Date).TotalDays >= MaxPeriodDays) return $"The period cannot exceed {MaxPeriodDays} days.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Unlike the standard warehouse lookup, this also serves inactive warehouses so their history stays viewable.</summary>
|
||||
public async Task<WarehouseDashboardResponse?> GetAsync(Guid id, DateTime? from, DateTime? to, int deadStockDays)
|
||||
{
|
||||
var warehouse = await warehouseRepo.GetByIdAsync(id);
|
||||
if (warehouse is null) return null;
|
||||
|
||||
var now = DateTime.Now;
|
||||
var today = now.Date;
|
||||
var toDate = (to ?? today).Date;
|
||||
var fromDate = (from ?? toDate.AddDays(-29)).Date;
|
||||
var toExclusive = toDate.AddDays(1);
|
||||
|
||||
var balances = await repo.GetBalanceRowsAsync(id);
|
||||
var movements = (await repo.GetMovementsAsync(id, fromDate, toExclusive))
|
||||
.Select(m => (Row: m, Direction: DirectionOf(m, id)))
|
||||
.Where(x => x.Direction is not null)
|
||||
.ToList();
|
||||
var lastOutbound = (await repo.GetLastOutboundAsync(id)).ToDictionary(r => r.ItemId, r => r.LastOutboundAt);
|
||||
|
||||
// ── Stock on hand ──────────────────────────────────────────────────
|
||||
var stock = balances
|
||||
.GroupBy(b => b.ItemId)
|
||||
.Select(g => BuildStockRow(g.ToList()))
|
||||
.OrderBy(r => r.Name)
|
||||
.ToList();
|
||||
|
||||
var stockByCategory = stock
|
||||
.Where(r => r.Quantity > 0)
|
||||
.GroupBy(r => r.Category)
|
||||
.Select(g => new DashboardCategoryStock(g.Key, g.Sum(r => r.Quantity), g.Sum(r => r.CostValue)))
|
||||
.OrderByDescending(c => c.Value)
|
||||
.ToList();
|
||||
|
||||
var itemNames = stock.ToDictionary(r => r.ItemId, r => r.Name);
|
||||
var expiring = balances
|
||||
.Where(b => b.Quantity > 0 && b.ExpiryDate.HasValue && b.BatchId.HasValue
|
||||
&& b.ExpiryDate.Value.Date <= today.AddDays(NearExpiryDays))
|
||||
.GroupBy(b => (b.ItemId, b.BatchId))
|
||||
.Select(g =>
|
||||
{
|
||||
var first = g.First();
|
||||
var expiry = first.ExpiryDate!.Value;
|
||||
return new DashboardExpiringBatch(
|
||||
first.ItemId, itemNames.GetValueOrDefault(first.ItemId, first.Name), first.BatchNumber,
|
||||
expiry, g.Sum(x => x.Quantity), expiry.Date < today ? "Expired" : "NearExpiry");
|
||||
})
|
||||
.OrderBy(b => b.ExpiryDate)
|
||||
.ToList();
|
||||
|
||||
// ── Movements ──────────────────────────────────────────────────────
|
||||
var unitsIn = movements.Where(x => x.Direction == "In").Sum(x => x.Row.Quantity);
|
||||
var unitsOut = movements.Where(x => x.Direction == "Out").Sum(x => x.Row.Quantity);
|
||||
|
||||
var perDay = movements
|
||||
.GroupBy(x => x.Row.CreatedAt.Date)
|
||||
.ToDictionary(g => g.Key, g => (
|
||||
In: g.Where(x => x.Direction == "In").Sum(x => x.Row.Quantity),
|
||||
Out: g.Where(x => x.Direction == "Out").Sum(x => x.Row.Quantity)));
|
||||
var daily = new List<DashboardDailyPoint>();
|
||||
for (var d = fromDate; d <= toDate; d = d.AddDays(1))
|
||||
{
|
||||
perDay.TryGetValue(d, out var p);
|
||||
daily.Add(new DashboardDailyPoint(d.ToString("yyyy-MM-dd"), p.In, p.Out));
|
||||
}
|
||||
|
||||
var byType = movements
|
||||
.GroupBy(x => (x.Row.Type, x.Direction))
|
||||
.Select(g => new DashboardMovementTypeRow(g.Key.Type, g.Key.Direction!, g.Sum(x => x.Row.Quantity), g.Count()))
|
||||
.OrderByDescending(r => r.Units)
|
||||
.ToList();
|
||||
|
||||
var ledgerSource = movements.Take(LedgerSize).ToList();
|
||||
var locationIds = ledgerSource
|
||||
.SelectMany(x => new[]
|
||||
{
|
||||
(x.Row.FromLocationId, x.Row.FromLocationType),
|
||||
(x.Row.ToLocationId, x.Row.ToLocationType),
|
||||
})
|
||||
.Where(l => l.Item1.HasValue && l.Item2 is LocationType t && t != LocationType.External)
|
||||
.Select(l => l.Item1!.Value);
|
||||
var locationNames = await repo.GetLocationNamesAsync(locationIds);
|
||||
var userNames = await repo.GetUserNamesAsync(ledgerSource.Select(x => x.Row.CreatedBy));
|
||||
|
||||
var ledger = ledgerSource.Select(x => new DashboardLedgerRow(
|
||||
x.Row.Id, x.Row.CreatedAt, x.Row.ItemId, x.Row.ItemName, x.Row.Sku,
|
||||
x.Row.Type, x.Direction!, x.Row.Quantity,
|
||||
SideName(x.Row.Type, x.Row.FromLocationId, x.Row.FromLocationType, locationNames, isFrom: true),
|
||||
SideName(x.Row.Type, x.Row.ToLocationId, x.Row.ToLocationType, locationNames, isFrom: false),
|
||||
x.Row.ReferenceId, ReferenceKind(x.Row.Type),
|
||||
x.Row.ReasonCode, userNames.GetValueOrDefault(x.Row.CreatedBy, "—"))).ToList();
|
||||
|
||||
// ── Inbound (GRN) ──────────────────────────────────────────────────
|
||||
var grnTotals = await repo.GetGrnTotalsAsync(id, fromDate, toExclusive);
|
||||
var received = grnTotals.Accepted + grnTotals.Rejected;
|
||||
var inbound = new DashboardInbound(
|
||||
grnTotals.Count, grnTotals.Accepted, grnTotals.Rejected,
|
||||
received == 0 ? 0m : Math.Round(grnTotals.Rejected * 100m / received, 1),
|
||||
await repo.GetRecentGrnsAsync(id, fromDate, toExclusive, RecentDocumentCount));
|
||||
|
||||
// ── Outbound (loading sheets) ──────────────────────────────────────
|
||||
var outbound = new DashboardOutbound(
|
||||
movements.Where(x => x.Row.Type == MovementType.Load && x.Direction == "Out").Sum(x => x.Row.Quantity),
|
||||
await repo.GetPendingDispatchUnitsAsync(id),
|
||||
await repo.GetRecentLoadingSheetsAsync(id, fromDate, toExclusive, RecentDocumentCount));
|
||||
|
||||
// ── Vehicles ───────────────────────────────────────────────────────
|
||||
var vehicleStock = (await repo.GetVehicleStockAsync(id, warehouse.VehicleId))
|
||||
.Select(v => new DashboardVehicle(v.VehicleId, v.RegNumber, v.NumberPlate, v.IsLinked, v.Units, v.Skus))
|
||||
.ToList();
|
||||
var linkedVehicles = await repo.GetDefaultVehiclesAsync(id, warehouse.VehicleId);
|
||||
|
||||
// ── Returns and losses ─────────────────────────────────────────────
|
||||
decimal Units(MovementType type, string direction) =>
|
||||
movements.Where(x => x.Row.Type == type && x.Direction == direction).Sum(x => x.Row.Quantity);
|
||||
var losses = new DashboardLosses(
|
||||
Units(MovementType.PurchaseReturn, "Out"), Units(MovementType.Damage, "Out"),
|
||||
Units(MovementType.Adjustment, "Out"), Units(MovementType.Adjustment, "In"),
|
||||
await repo.GetOpenClaimCountAsync(id),
|
||||
await repo.GetOpenClaimsAsync(id, RecentDocumentCount));
|
||||
|
||||
// ── Top movers and dead stock ──────────────────────────────────────
|
||||
var topMovers = movements
|
||||
.Where(x => x.Row.Type == MovementType.Load && x.Direction == "Out")
|
||||
.GroupBy(x => x.Row.ItemId)
|
||||
.Select(g => new DashboardTopMover(g.Key, g.First().Row.Sku, g.First().Row.ItemName, g.Sum(x => x.Row.Quantity)))
|
||||
.OrderByDescending(m => m.UnitsOut)
|
||||
.Take(TopListSize)
|
||||
.ToList();
|
||||
|
||||
var deadCutoff = now.AddDays(-deadStockDays);
|
||||
var deadStock = stock
|
||||
.Where(r => r.Quantity > 0 && r.UpdatedAt < deadCutoff
|
||||
&& (!lastOutbound.TryGetValue(r.ItemId, out var last) || last < deadCutoff))
|
||||
.OrderByDescending(r => r.CostValue)
|
||||
.Take(DeadStockListSize)
|
||||
.Select(r => new DashboardDeadStock(
|
||||
r.ItemId, r.Sku, r.Name, r.Quantity, r.CostValue,
|
||||
lastOutbound.TryGetValue(r.ItemId, out var last) ? last : null))
|
||||
.ToList();
|
||||
|
||||
var kpis = new DashboardKpis(
|
||||
stock.Sum(r => r.CostValue), stock.Sum(r => r.SaleValue),
|
||||
stock.Where(r => r.Quantity > 0).Sum(r => r.Quantity), stock.Count(r => r.Quantity > 0),
|
||||
stock.Count(r => r.Status == "Low"), stock.Count(r => r.Status == "Out"),
|
||||
expiring.Count(b => b.Status == "NearExpiry"), expiring.Count(b => b.Status == "Expired"),
|
||||
unitsIn, unitsOut);
|
||||
|
||||
return new WarehouseDashboardResponse(
|
||||
new WarehouseResponse(warehouse.Id, warehouse.Name, warehouse.Location, warehouse.Type,
|
||||
warehouse.VehicleId, warehouse.IsActive, warehouse.CreatedAt),
|
||||
linkedVehicles, new DashboardPeriod(fromDate, toDate), deadStockDays, kpis,
|
||||
stock, stockByCategory, expiring, daily, byType, ledger,
|
||||
inbound, outbound, vehicleStock, losses, topMovers, deadStock);
|
||||
}
|
||||
|
||||
private static DashboardStockRow BuildStockRow(List<WarehouseBalanceRow> rows)
|
||||
{
|
||||
var first = rows[0];
|
||||
var quantity = rows.Sum(r => r.Quantity);
|
||||
var billable = Math.Max(quantity, 0m);
|
||||
var status = quantity <= 0 ? "Out"
|
||||
: first.ReorderLevel.HasValue && quantity < first.ReorderLevel.Value ? "Low"
|
||||
: "OK";
|
||||
var batches = rows
|
||||
.Where(r => r.BatchId.HasValue && r.Quantity > 0)
|
||||
.GroupBy(r => r.BatchId!.Value)
|
||||
.Select(g => new DashboardBatch(g.Key, g.First().BatchNumber, g.First().ExpiryDate, g.Sum(r => r.Quantity)))
|
||||
.OrderBy(b => b.ExpiryDate ?? DateTime.MaxValue)
|
||||
.ToList();
|
||||
|
||||
return new DashboardStockRow(
|
||||
first.ItemId, first.Sku, first.Name, first.Category, first.Brand, first.Uom,
|
||||
quantity, first.ReorderLevel, status,
|
||||
billable * (first.CostPrice ?? 0m), billable * (first.SalePrice ?? 0m),
|
||||
rows.Max(r => r.UpdatedAt), batches);
|
||||
}
|
||||
|
||||
private static string? DirectionOf(WarehouseMovementRow m, Guid warehouseId) =>
|
||||
m.ToLocationId == warehouseId && m.FromLocationId != warehouseId ? "In"
|
||||
: m.FromLocationId == warehouseId && m.ToLocationId != warehouseId ? "Out"
|
||||
: null;
|
||||
|
||||
private static string? ReferenceKind(MovementType type) => type switch
|
||||
{
|
||||
MovementType.PurchaseReceipt => "GRN",
|
||||
MovementType.Load => "Loading Sheet",
|
||||
MovementType.PurchaseReturn => "Purchase Return",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
private static string SideName(
|
||||
MovementType type, Guid? id, LocationType? locationType, Dictionary<Guid, string> names, bool isFrom)
|
||||
{
|
||||
if (id is not Guid locId || locationType is not LocationType lt) return "—";
|
||||
if (lt != LocationType.External) return names.GetValueOrDefault(locId, "—");
|
||||
return type switch
|
||||
{
|
||||
MovementType.Sale or MovementType.CustomerReturn => "Customer",
|
||||
MovementType.PurchaseReceipt or MovementType.PurchaseReturn => "Supplier",
|
||||
MovementType.Damage => "Written Off",
|
||||
MovementType.Adjustment => "Stock Adjustment",
|
||||
_ => isFrom ? "External Source" : "External Destination",
|
||||
};
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,11 +1,12 @@
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace Distribution.Features.Auth;
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Proxies own-user auth calls (login/register/getUserDetails/logout) to the external AuthHex
|
||||
/// identity service. AuthHex owns credentials and issues the RS256-signed JWT this app validates;
|
||||
/// this app never sees or stores a plaintext/hashed password.
|
||||
/// identity service. AuthHex owns credentials and issues the RS256-signed JWT this app validates
|
||||
/// (see JwtTokenService's replacement — token generation is no longer done locally); this app
|
||||
/// never sees or stores a plaintext/hashed password for the AuthHex-authenticated flow.
|
||||
/// </summary>
|
||||
public class AuthHexClient(HttpClient http) : IAuthHexClient
|
||||
{
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Distribution.Features.Auth;
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
/// <summary>Raw response shape returned by AuthHex's `/api/user` endpoint for every functionName.</summary>
|
||||
public record AuthHexResponse(
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Distribution.Features.Auth;
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public interface IAuthHexClient
|
||||
{
|
||||
@@ -0,0 +1,14 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class AuthenticatedAttribute : Attribute, IAuthorizationFilter
|
||||
{
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
if (context.HttpContext.User.Identity?.IsAuthenticated != true)
|
||||
context.Result = new UnauthorizedResult();
|
||||
}
|
||||
}
|
||||
+1
-21
@@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
@@ -17,14 +17,6 @@ public class AuthorizationController(
|
||||
return Ok(new PermissionCheckResponse(result));
|
||||
}
|
||||
|
||||
[HttpGet("my-permissions")]
|
||||
public async Task<IActionResult> GetMyPermissions()
|
||||
{
|
||||
if (currentUser.RoleId is not { } roleId) return Unauthorized();
|
||||
var permissions = await permissionService.GetRolePermissionsAsync(roleId);
|
||||
return Ok(new RolePermissionsResponse(permissions));
|
||||
}
|
||||
|
||||
[HttpGet("scopes/stores/{storeId:guid}")]
|
||||
public async Task<IActionResult> CheckStoreScope(Guid storeId)
|
||||
{
|
||||
@@ -57,15 +49,3 @@ public class AuthorizationController(
|
||||
return Ok(new AccessibleStoresResponse(result));
|
||||
}
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("api/permissions")]
|
||||
public class PermissionController(IPermissionService permissionService) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var permissions = await permissionService.GetAllAsync();
|
||||
return Ok(permissions.Select(p => new { permissionId = p.Id, p.Code, p.Description }));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public class CurrentUserService : ICurrentUserService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public CurrentUserService(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
private System.Security.Claims.ClaimsPrincipal? User => _httpContextAccessor.HttpContext?.User;
|
||||
|
||||
public bool IsAuthenticated => User?.Identity?.IsAuthenticated ?? false;
|
||||
|
||||
public Guid? UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = User?.FindFirst("sub")?.Value ?? User?.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value;
|
||||
return Guid.TryParse(value, out var id) ? id : null;
|
||||
}
|
||||
}
|
||||
|
||||
public Guid? RoleId
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = User?.FindFirst("role_id")?.Value;
|
||||
return Guid.TryParse(value, out var id) ? id : null;
|
||||
}
|
||||
}
|
||||
|
||||
public string? Username => User?.FindFirst("username")?.Value;
|
||||
|
||||
public int RoleLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = User?.FindFirst("role_level")?.Value;
|
||||
return int.TryParse(value, out var level) ? level : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -4,8 +4,7 @@ public interface ICurrentUserService
|
||||
{
|
||||
Guid? UserId { get; }
|
||||
Guid? RoleId { get; }
|
||||
string? Username { get; }
|
||||
int RoleLevel { get; }
|
||||
bool IsAuthenticated { get; }
|
||||
Task<string?> GetUsernameAsync();
|
||||
Task<string?> GetRoleCodeAsync();
|
||||
Task<int> GetRoleLevelAsync();
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System.Security.Claims;
|
||||
using Distribution.Data;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public class CurrentUserService(IHttpContextAccessor http, AppDBContext db, IMemoryCache cache) : ICurrentUserService
|
||||
{
|
||||
private ClaimsPrincipal? User => http.HttpContext?.User;
|
||||
|
||||
public bool IsAuthenticated => User?.Identity?.IsAuthenticated ?? false;
|
||||
public Guid? UserId => Guid.TryParse(User?.FindFirst("UserId")?.Value, out var id) ? id : null;
|
||||
public Guid? RoleId => Guid.TryParse(User?.FindFirst("RoleId")?.Value, out var id) ? id : null;
|
||||
|
||||
public async Task<string?> GetUsernameAsync()
|
||||
{
|
||||
if (UserId is not { } id) return null;
|
||||
var key = $"user_rolename_{id}";
|
||||
if (cache.TryGetValue(key, out string? cached)) return cached;
|
||||
var user = await db.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == id);
|
||||
cache.Set(key, user?.Username, TimeSpan.FromMinutes(10));
|
||||
return user?.Username;
|
||||
}
|
||||
|
||||
public async Task<string?> GetRoleCodeAsync()
|
||||
{
|
||||
if (RoleId is not { } id) return null;
|
||||
var key = $"role_name_{id}";
|
||||
if (cache.TryGetValue(key, out string? cached)) return cached;
|
||||
var role = await db.Roles.AsNoTracking().FirstOrDefaultAsync(r => r.Id == id);
|
||||
cache.Set(key, role?.Name, TimeSpan.FromMinutes(10));
|
||||
return role?.Name;
|
||||
}
|
||||
|
||||
public async Task<int> GetRoleLevelAsync()
|
||||
{
|
||||
if (RoleId is not { } id) return 0;
|
||||
var key = $"role_level_{id}";
|
||||
if (cache.TryGetValue(key, out int cached)) return cached;
|
||||
var role = await db.Roles.AsNoTracking().FirstOrDefaultAsync(r => r.Id == id);
|
||||
var level = role?.Level ?? 0;
|
||||
cache.Set(key, level, TimeSpan.FromMinutes(10));
|
||||
return level;
|
||||
}
|
||||
}
|
||||
-2
@@ -2,8 +2,6 @@ namespace Distribution.Infra.Authorization;
|
||||
|
||||
public record PermissionCheckResponse(bool HasPermission);
|
||||
|
||||
public record RolePermissionsResponse(List<string> Permissions);
|
||||
|
||||
public record StoreScopeCheckResponse(bool HasScope);
|
||||
|
||||
public record RouteScopeCheckResponse(bool HasScope);
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Parses an XML-format RSA public key (`<RSAKeyValue>...</RSAKeyValue>`, as issued by
|
||||
/// AuthHex) into an <see cref="RSA"/> instance. Written by hand instead of relying on
|
||||
/// RSA.FromXmlString, which is Windows-only in .NET (throws PlatformNotSupportedException on
|
||||
/// Linux/macOS) — this keeps token validation portable across hosts.
|
||||
/// </summary>
|
||||
public static class RsaXmlKeyReader
|
||||
{
|
||||
public static RSA ReadPublicKey(string xml)
|
||||
{
|
||||
var root = XElement.Parse(xml);
|
||||
var modulus = root.Element("Modulus")?.Value
|
||||
?? throw new InvalidOperationException("RSA XML key is missing <Modulus>.");
|
||||
var exponent = root.Element("Exponent")?.Value
|
||||
?? throw new InvalidOperationException("RSA XML key is missing <Exponent>.");
|
||||
|
||||
var parameters = new RSAParameters
|
||||
{
|
||||
Modulus = Convert.FromBase64String(modulus),
|
||||
Exponent = Convert.FromBase64String(exponent)
|
||||
};
|
||||
|
||||
var rsa = RSA.Create();
|
||||
rsa.ImportParameters(parameters);
|
||||
return rsa;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Distribution.Infra.Authorization.Middleware;
|
||||
|
||||
/// <summary>Stand-in for OSMCore's OMSCore.Common.Models.IOs.ApiResponse<T>, which has no equivalent in this project.</summary>
|
||||
public sealed record ApiResponse<T>
|
||||
{
|
||||
public int StatusCode { get; init; }
|
||||
public bool Success { get; init; }
|
||||
public string? Message { get; init; }
|
||||
public T? Data { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Distribution.Infra.Authorization.Middleware;
|
||||
|
||||
/// <summary>
|
||||
/// Ported from OSMCore's System/Authentication/JwtOptions.cs. Binds to the same "Jwt" config
|
||||
/// section already used by Program.cs's AddJwtBearer setup (Jwt:PublicKey/Audience/Issuer) — no
|
||||
/// new config keys needed.
|
||||
/// </summary>
|
||||
public sealed record JwtOptions
|
||||
{
|
||||
public string PublicKey { get; init; } = string.Empty;
|
||||
public string Audience { get; init; } = string.Empty;
|
||||
public string Issuer { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public interface IPermissionRepository
|
||||
{
|
||||
Task<bool> HasPermissionAsync(Guid roleId, string permissionCode);
|
||||
Task<List<string>> GetRolePermissionsAsync(Guid roleId);
|
||||
Task<List<Permission>> GetAllAsync();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public interface IPermissionService
|
||||
{
|
||||
Task<bool> HasPermissionAsync(Guid roleId, string permissionCode);
|
||||
Task<List<string>> GetRolePermissionsAsync(Guid roleId);
|
||||
Task<List<Permission>> GetAllAsync();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
@@ -11,15 +10,4 @@ public class PermissionRepository(AppDBContext context) : IPermissionRepository
|
||||
.Where(rp => rp.FK_RoleId == roleId && rp.IsActive)
|
||||
.Join(context.Permissions.Where(p => p.IsActive), rp => rp.FK_PermissionId, p => p.Id, (rp, p) => p.Code)
|
||||
.AnyAsync(code => code == permissionCode);
|
||||
|
||||
public Task<List<string>> GetRolePermissionsAsync(Guid roleId) =>
|
||||
context.RolePermissions
|
||||
.Where(rp => rp.FK_RoleId == roleId && rp.IsActive)
|
||||
.Select(rp => rp.Permission)
|
||||
.Where(p => p.IsActive)
|
||||
.Select(p => p.Code)
|
||||
.ToListAsync();
|
||||
|
||||
public Task<List<Permission>> GetAllAsync() =>
|
||||
context.Permissions.Where(p => p.IsActive).ToListAsync();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public class PermissionService(IPermissionRepository repo) : IPermissionService
|
||||
{
|
||||
public Task<bool> HasPermissionAsync(Guid roleId, string permissionCode) =>
|
||||
repo.HasPermissionAsync(roleId, permissionCode);
|
||||
|
||||
public Task<List<string>> GetRolePermissionsAsync(Guid roleId) =>
|
||||
repo.GetRolePermissionsAsync(roleId);
|
||||
|
||||
public Task<List<Permission>> GetAllAsync() =>
|
||||
repo.GetAllAsync();
|
||||
}
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
//namespace Distribution.Infra.Authorization;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
//public class PermissionAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
|
||||
//{
|
||||
// private readonly IPermissionService _permissionService;
|
||||
|
||||
public class PermissionAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
|
||||
{
|
||||
private readonly IPermissionService _permissionService;
|
||||
// public PermissionAuthorizationHandler(IPermissionService permissionService)
|
||||
// {
|
||||
// _permissionService = permissionService;
|
||||
// }
|
||||
|
||||
public PermissionAuthorizationHandler(IPermissionService permissionService)
|
||||
{
|
||||
_permissionService = permissionService;
|
||||
}
|
||||
// protected override async Task HandleRequirementAsync(
|
||||
// AuthorizationHandlerContext context, PermissionRequirement requirement)
|
||||
// {
|
||||
// var roleIdClaim = context.User.FindFirst("role_id")?.Value;
|
||||
// if (!Guid.TryParse(roleIdClaim, out var roleId))
|
||||
// return;
|
||||
|
||||
protected override async Task HandleRequirementAsync(
|
||||
AuthorizationHandlerContext context, PermissionRequirement requirement)
|
||||
{
|
||||
var roleIdClaim = context.User.FindFirst("RoleId")?.Value;
|
||||
if (!Guid.TryParse(roleIdClaim, out var roleId))
|
||||
return;
|
||||
|
||||
if (await _permissionService.HasPermissionAsync(roleId, requirement.PermissionCode))
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
}
|
||||
// if (await _permissionService.HasPermissionAsync(roleId, requirement.PermissionCode))
|
||||
// context.Succeed(requirement);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Options;
|
||||
//using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
//namespace Distribution.Infra.Authorization;
|
||||
|
||||
public class PermissionPolicyProvider : IAuthorizationPolicyProvider
|
||||
{
|
||||
private readonly DefaultAuthorizationPolicyProvider _fallback;
|
||||
//public class PermissionPolicyProvider : IAuthorizationPolicyProvider
|
||||
//{
|
||||
// private readonly DefaultAuthorizationPolicyProvider _fallback;
|
||||
|
||||
public PermissionPolicyProvider(IOptions<AuthorizationOptions> options)
|
||||
{
|
||||
_fallback = new DefaultAuthorizationPolicyProvider(options);
|
||||
}
|
||||
// public PermissionPolicyProvider(IOptions<AuthorizationOptions> options)
|
||||
// {
|
||||
// _fallback = new DefaultAuthorizationPolicyProvider(options);
|
||||
// }
|
||||
|
||||
public Task<AuthorizationPolicy> GetDefaultPolicyAsync() => _fallback.GetDefaultPolicyAsync();
|
||||
// public Task<AuthorizationPolicy> GetDefaultPolicyAsync() => _fallback.GetDefaultPolicyAsync();
|
||||
|
||||
public Task<AuthorizationPolicy?> GetFallbackPolicyAsync() => _fallback.GetFallbackPolicyAsync();
|
||||
// public Task<AuthorizationPolicy?> GetFallbackPolicyAsync() => _fallback.GetFallbackPolicyAsync();
|
||||
|
||||
public Task<AuthorizationPolicy?> GetPolicyAsync(string policyName)
|
||||
{
|
||||
if (policyName.Contains('.'))
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder()
|
||||
.RequireAuthenticatedUser()
|
||||
.AddRequirements(new PermissionRequirement(policyName))
|
||||
.Build();
|
||||
return Task.FromResult<AuthorizationPolicy?>(policy);
|
||||
}
|
||||
// public Task<AuthorizationPolicy?> GetPolicyAsync(string policyName)
|
||||
// {
|
||||
// if (policyName.Contains('.'))
|
||||
// {
|
||||
// var policy = new AuthorizationPolicyBuilder()
|
||||
// .RequireAuthenticatedUser()
|
||||
// .AddRequirements(new PermissionRequirement(policyName))
|
||||
// .Build();
|
||||
// return Task.FromResult<AuthorizationPolicy?>(policy);
|
||||
// }
|
||||
|
||||
return _fallback.GetPolicyAsync(policyName);
|
||||
}
|
||||
}
|
||||
// return _fallback.GetPolicyAsync(policyName);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
//namespace Distribution.Infra.Authorization;
|
||||
|
||||
namespace Distribution.Infra.Authorization;
|
||||
//public class PermissionRequirement : IAuthorizationRequirement
|
||||
//{
|
||||
// public string PermissionCode { get; }
|
||||
|
||||
public class PermissionRequirement : IAuthorizationRequirement
|
||||
{
|
||||
public string PermissionCode { get; }
|
||||
|
||||
public PermissionRequirement(string permissionCode)
|
||||
{
|
||||
PermissionCode = permissionCode;
|
||||
}
|
||||
}
|
||||
// public PermissionRequirement(string permissionCode)
|
||||
// {
|
||||
// PermissionCode = permissionCode;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace Distribution.Middleware;
|
||||
@@ -13,24 +13,18 @@ public class AuthMiddleware(RequestDelegate next, IConfiguration config)
|
||||
.Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase)
|
||||
.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
token = context.Request.Cookies["access-token"] ?? string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
var publicKeyXml = config["Jwt:PublicKey"];
|
||||
if (!string.IsNullOrEmpty(publicKeyXml))
|
||||
var key = config["Jwt:Key"];
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
try
|
||||
{
|
||||
var rsa = RSA.Create();
|
||||
rsa.FromXmlString(publicKeyXml);
|
||||
var principal = new JwtSecurityTokenHandler().ValidateToken(token,
|
||||
new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new RsaSecurityKey(rsa),
|
||||
ValidAlgorithms = [SecurityAlgorithms.RsaSha256],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key)),
|
||||
ValidateIssuer = true,
|
||||
ValidIssuer = config["Jwt:Issuer"],
|
||||
ValidateAudience = true,
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text.Encodings.Web;
|
||||
|
||||
namespace Distribution.Middleware;
|
||||
|
||||
/// <summary>
|
||||
/// Authentication handler that exists solely to provide Challenge (401) and Forbid (403)
|
||||
/// responses for UseAuthorization(). Token validation is handled upstream by AuthMiddleware,
|
||||
/// so HandleAuthenticateAsync returns NoResult to leave HttpContext.User untouched.
|
||||
/// </summary>
|
||||
public class BearerResponseHandler(
|
||||
IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||
ILoggerFactory logger,
|
||||
UrlEncoder encoder) : AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
|
||||
{
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync() =>
|
||||
Task.FromResult(AuthenticateResult.NoResult());
|
||||
|
||||
protected override Task HandleChallengeAsync(AuthenticationProperties properties)
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override Task HandleForbiddenAsync(AuthenticationProperties properties)
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
-4423
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SeedPermissionsAndRolePermissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-4433
File diff suppressed because it is too large
Load Diff
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class user : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "Users",
|
||||
columns: new[] { "Id", "CreatedAt", "FK_ReportsToUserId", "FK_RoleId", "FullName", "IsActive", "PasswordHash", "UpdatedAt", "Username" },
|
||||
values: new object[] { new Guid("00000001-0000-0000-0000-000000000001"), new DateTime(2026, 10, 13, 0, 0, 0, 0, DateTimeKind.Unspecified), null, new Guid("10000000-0000-0000-0000-000000000006"), "Super Admin", true, "N/A", null, "superadmin" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("00000001-0000-0000-0000-000000000001"));
|
||||
}
|
||||
}
|
||||
}
|
||||
-4749
File diff suppressed because it is too large
Load Diff
@@ -1,287 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class seed_permissions_and_superadmin : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "Permissions",
|
||||
columns: new[] { "Id", "Code", "CreatedAt", "Description", "IsActive" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("20000000-0000-0000-0000-000000000001"), "orders.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View shop POs, invoices, payments and returns", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000002"), "rides.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage delivery rides and delivery tasks", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000003"), "loading.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage loading sheets", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000004"), "stores.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View store accounts, credit limits and balances", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000005"), "sales_visits.checkin", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Check in and out of scheduled store visits", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000006"), "items.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage catalogue products", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000007"), "categories.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage product categories and brands", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000008"), "warehouses.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View stock balances, movements, warehouses and reports", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000009"), "purchase_orders.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage purchase orders, GRNs and supplier claims", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000010"), "pricelists.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage regional price lists", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000011"), "schemes.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage pricing schemes and promotions", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000012"), "suppliers.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage supplier accounts", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000013"), "driver_profiles.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage driver profiles and licensing", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000014"), "compliance.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Manage driver compliance rules", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000015"), "users.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage staff user accounts", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000016"), "roles.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage roles and their permission sets", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000017"), "regions.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage regions and region configuration", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000018"), "routes.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage delivery routes", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000019"), "vehicles.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View and manage fleet vehicles", true }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Roles",
|
||||
columns: new[] { "Id", "CreatedAt", "IsActive", "Level", "Name" },
|
||||
values: new object[] { new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 100, "SuperAdmin" });
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("00000001-0000-0000-0000-000000000001"),
|
||||
column: "FK_RoleId",
|
||||
value: new Guid("10000000-0000-0000-0000-000000000007"));
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "RolePermissions",
|
||||
columns: new[] { "FK_PermissionId", "FK_RoleId", "CreatedAt", "Id", "IsActive" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("18023ad9-33e9-4a8c-81ab-dc53a932bdb7"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("825d5a5f-2c80-4082-8c33-d49aa37feaae"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("a1e975e8-0444-44f4-99c9-ecb145f5e178"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("fa741a9c-6ea9-4b44-bc1c-98251e2ce264"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("fd511b82-6a48-459e-8da8-8db040b8b5a6"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("92e7a255-974a-47e1-94bd-227f2b40f61f"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("b82510e3-b3c1-4f41-97f9-e76790f9728c"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("4b35173b-142c-4387-8991-604d32f6dc27"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("c41ce69f-e683-4c3f-8e5c-f7b0f06f6496"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("7aa9f9a1-3c36-4141-97cd-074f47ba6c5a"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("deb01208-aca1-473f-ae08-1f64f54ddd6c"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("3c426f42-2433-489b-a85c-7d94ca0290f6"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("3ed4863f-6683-47e2-b4f4-89f73655c461"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("f4346c74-c269-4bf1-9626-e7670d8075ef"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("3ca2691e-ae21-436e-9204-1333a727ffd4"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("b86df36b-17c4-4d3e-a102-4aa2f2d8e2c3"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("8c82e198-b505-428b-b1a0-05eb8207bd5d"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("a3c69976-d0d6-4890-be7e-5e40f1d36506"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("ba9dc1ed-beea-424b-9db0-30e4825ab011"), true }
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000001"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000002"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000003"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000004"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000005"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000006"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000007"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000008"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000009"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000010"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000011"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000012"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000013"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000014"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000015"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000016"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000017"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000018"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000019"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Roles",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("10000000-0000-0000-0000-000000000007"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("00000001-0000-0000-0000-000000000001"),
|
||||
column: "FK_RoleId",
|
||||
value: new Guid("10000000-0000-0000-0000-000000000006"));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,285 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class useradmin : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7475d3c3-2388-4939-8a09-d7879ffd81c9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e8303485-de75-4541-8616-3dc3d043dead"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("63baa4e1-e268-4afb-b045-0bbc89b6e559"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c75fddcd-7f32-4878-8558-9a70fc752760"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4fcfb308-625f-42e0-b54e-ddfb8beaf7a6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("09d70c50-aa17-4e21-bbef-8f800c009c38"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5201456f-d2d1-47d8-a1be-a74f89d2598e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e4d7f7f9-4149-41af-a79f-d37845dfb30b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e796d680-ac2e-4e8e-aa39-86137067714a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("97b043ea-aa01-4c3e-81ee-e9e91f1f9f8a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f04db587-2f88-4e9f-9ccf-4ac650aea07b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("372a968b-a962-4a60-afd6-1b69a6a5dd3f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2dd911e7-2217-4dd1-b0aa-18ae5983c6af"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("03f4ab42-49dc-4aac-912b-a0a14415cf87"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d9522f5e-963a-4670-8241-35e65a349970"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2f789a49-103e-4ad9-adda-9ab1cd2e86d9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("17d668ef-09e7-4886-af6e-63817bf25a1b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8b90d8fa-ca60-4eca-a0ba-02a32d99bf50"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("17e9237e-b390-4779-ab51-0e872c25c67d"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("18023ad9-33e9-4a8c-81ab-dc53a932bdb7"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("825d5a5f-2c80-4082-8c33-d49aa37feaae"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a1e975e8-0444-44f4-99c9-ecb145f5e178"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fa741a9c-6ea9-4b44-bc1c-98251e2ce264"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fd511b82-6a48-459e-8da8-8db040b8b5a6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("92e7a255-974a-47e1-94bd-227f2b40f61f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b82510e3-b3c1-4f41-97f9-e76790f9728c"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4b35173b-142c-4387-8991-604d32f6dc27"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c41ce69f-e683-4c3f-8e5c-f7b0f06f6496"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7aa9f9a1-3c36-4141-97cd-074f47ba6c5a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("deb01208-aca1-473f-ae08-1f64f54ddd6c"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3c426f42-2433-489b-a85c-7d94ca0290f6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3ed4863f-6683-47e2-b4f4-89f73655c461"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f4346c74-c269-4bf1-9626-e7670d8075ef"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3ca2691e-ae21-436e-9204-1333a727ffd4"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b86df36b-17c4-4d3e-a102-4aa2f2d8e2c3"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8c82e198-b505-428b-b1a0-05eb8207bd5d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a3c69976-d0d6-4890-be7e-5e40f1d36506"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ba9dc1ed-beea-424b-9db0-30e4825ab011"));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,673 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class userpermissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.InsertData(
|
||||
table: "Permissions",
|
||||
columns: new[] { "Id", "Code", "CreatedAt", "Description", "IsActive" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("20000000-0000-0000-0000-000000000020"), "claim.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View agency claims and settlement status", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000021"), "claim.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and settle agency claims", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000022"), "delivery-task.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View delivery tasks within a ride", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000023"), "delivery-task.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Confirm and fail delivery tasks", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000024"), "driver.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View driver profiles and license details", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000025"), "driver.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and update driver profiles", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000026"), "grn.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View goods receipt notes", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000027"), "grn.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and confirm goods receipts", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000028"), "loading-sheet.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View loading sheets and their items", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000029"), "loading-sheet.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create, edit, and confirm loading sheets", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000030"), "price-list.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View regional price lists", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000031"), "price-list.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and manage item price lists", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000032"), "purchase-order.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View purchase orders and line items", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000033"), "purchase-order.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create, confirm, and close purchase orders", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000034"), "purchase-return.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and manage purchase returns to suppliers", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000035"), "region.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View regions and their configuration", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000036"), "region.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and update regions, targets, and budgets", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000037"), "return.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View order returns", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000038"), "return.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and manage order returns", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000039"), "route.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View delivery routes", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000040"), "route.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and manage delivery routes", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000041"), "scheme.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View pricing schemes and promotions", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000042"), "scheme.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and configure pricing schemes", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000043"), "stock.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View stock balances and movements", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000044"), "stock.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Transfer stock and record damage or adjustments", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000045"), "store.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View store accounts and balances", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000046"), "store.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and update store accounts", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000047"), "supplier-claim.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View supplier claims", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000048"), "supplier-claim.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Create and resolve supplier claims", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000049"), "sys-config.view", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "View system configuration settings", true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000050"), "sys-config.manage", new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), "Update system configuration settings", true }
|
||||
});
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e7ab6e43-7142-456e-a7f4-41a98daafbd9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("38c173a0-6fb4-475e-8743-643b143cde23"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("587c3956-3c69-49da-8839-5bee906ac5bd"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7e1a8a4d-807b-4b3d-ad76-21ab2b4b5a65"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5272f534-dba6-4899-8661-5687fffef070"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b3cd2db4-f3c4-44cc-bc94-d3b39f4c4672"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f9483ce1-aa1a-409e-a618-d049642f8972"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1e82cd6b-7024-4a5e-a987-b7c6f2ff706e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("64171cfe-734a-4f02-adc4-20a51cc7526f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fd7bcaf8-2022-4cdb-8964-76d5e98a4cfb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bb8e7d27-eebe-4cd9-91ec-124397e69040"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0f85f8d1-40c9-49f7-9bbd-35aead4f4bc8"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("defa1474-5a40-4def-9759-a3130859584d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("02e29292-1019-42de-a4d8-d4f125892d51"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("172a530b-a9c9-41f7-b523-174d77ff1dd2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8a5a322d-c2b6-428b-8f78-f743cf5abfef"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cba0ecc5-2219-437c-8cfc-b989d6274261"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("aefa2578-8a39-45cd-b054-e86e15199831"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a8cd8a2e-3e24-4768-9203-70d2323a535b"));
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "RolePermissions",
|
||||
columns: new[] { "FK_PermissionId", "FK_RoleId", "CreatedAt", "Id", "IsActive" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("e46f2b96-2913-4536-a427-b67a792cba72"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("f727a037-c5a2-4745-b426-703b3e73d651"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("4ef8970e-3f1b-49bd-a30d-289c4584da3b"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("00531be2-4d6d-492d-8ab8-72d5e94c36f0"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("5b6a5647-5a28-4326-8802-1d13ecfc94b1"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("69ec8424-eab4-45a6-a503-941d5738d3f9"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("f6d80758-8221-41b8-9099-c6bae5611f86"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("db1dd417-9733-46e0-ab24-b174da6197e9"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("a04196e8-d113-433f-a672-317f7f0d4faa"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("2a15a3df-317f-4f0f-abc7-360c8ec97fbb"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("68b90295-945a-430e-afdc-16bb61ef5d43"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("7fa5ec71-edb1-4687-a95f-a506a794626a"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("d3fef7f2-d827-4064-a900-9f872647eb82"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("88c098e2-d32a-40ff-9832-a08977c6adb0"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("e77ea9ea-20e5-4689-af38-a21489ffb9fd"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("47efe028-429d-4213-a86f-62a5c88e9cbf"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("025cf58c-b01a-4d27-ae0e-395c9b0f7e55"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("88a3c70e-cc58-4844-ae2c-4670784c2977"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("63994f0c-edb8-4ac4-9d06-3f433799dd1a"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("a167986f-164e-4e3b-876e-2113cba53d51"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("2a470650-ecb2-488d-a3ad-ea4afe51de29"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("f0882a97-6eed-4800-830e-0ad60df76b56"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("d5afb82e-2001-4ef7-87b0-b0a510919f6b"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("79ed7453-80b7-499f-b9fd-41d5aa0c258c"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("bb0ae3a2-0dfd-41ae-898d-02fbc31636e8"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("7f176330-117a-4dd2-931f-eb0543818378"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("0ac9e74e-34ae-48b2-af29-0646c443cc6d"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("37bda3bc-88df-45e2-9cf5-5014df0df5c0"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("209149dc-eb8d-4825-9ee1-9aea3d8a8371"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("961f7973-672b-4837-b16f-d0976ccd3d14"), true },
|
||||
{ new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), new Guid("d0908026-efc0-4226-95b7-340e03add727"), true }
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") });
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000020"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000021"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000022"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000023"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000024"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000025"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000026"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000027"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000028"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000029"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000030"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000031"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000032"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000033"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000034"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000035"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000036"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000037"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000038"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000039"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000040"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000041"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000042"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000043"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000044"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000045"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000046"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000047"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000048"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000049"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Permissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("20000000-0000-0000-0000-000000000050"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7475d3c3-2388-4939-8a09-d7879ffd81c9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e8303485-de75-4541-8616-3dc3d043dead"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("63baa4e1-e268-4afb-b045-0bbc89b6e559"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c75fddcd-7f32-4878-8558-9a70fc752760"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4fcfb308-625f-42e0-b54e-ddfb8beaf7a6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("09d70c50-aa17-4e21-bbef-8f800c009c38"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5201456f-d2d1-47d8-a1be-a74f89d2598e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e4d7f7f9-4149-41af-a79f-d37845dfb30b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e796d680-ac2e-4e8e-aa39-86137067714a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("97b043ea-aa01-4c3e-81ee-e9e91f1f9f8a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f04db587-2f88-4e9f-9ccf-4ac650aea07b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("372a968b-a962-4a60-afd6-1b69a6a5dd3f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2dd911e7-2217-4dd1-b0aa-18ae5983c6af"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("03f4ab42-49dc-4aac-912b-a0a14415cf87"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d9522f5e-963a-4670-8241-35e65a349970"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2f789a49-103e-4ad9-adda-9ab1cd2e86d9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("17d668ef-09e7-4886-af6e-63817bf25a1b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8b90d8fa-ca60-4eca-a0ba-02a32d99bf50"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("17e9237e-b390-4779-ab51-0e872c25c67d"));
|
||||
}
|
||||
}
|
||||
}
|
||||
-5245
File diff suppressed because it is too large
Load Diff
@@ -1,719 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class seed_granular_permissions : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2933abc2-b472-4870-8af7-a54a3adc4163"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d599d707-9645-4aad-8277-b492b2284eca"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("912132ef-5996-4a7f-acdf-e70a8aebec61"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3193b6b5-8656-41a5-88f1-264cda89dc38"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("33a3bace-319c-4394-a8ca-66f4983e8a65"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d67d727b-6bc6-437e-b52a-69bc6a78a009"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("03c210fa-f841-4262-96a8-d167bcca84de"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4949daa6-2136-400a-8b92-a0650ebd433d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("abd013d2-5d26-4e08-ab9c-506a8bd8a4fc"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f6ea9dbf-42ec-4fdf-b61a-5359f302e3de"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1a6d4dfe-32f5-4860-8c0c-3109f6dbdc56"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6387f234-eb63-43f1-8b20-1262cc646ef7"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bf6e1071-4c1e-45ba-ac90-54935832ab33"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2e009c83-d9be-41b1-9cfb-a720671f9531"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0a1c09c4-4851-4c03-a728-be2be77425cb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6d5cfd42-9ad3-4c6a-81c1-27c92fa70746"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cdd856de-60ba-431a-9c18-59368cf5f325"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("28ecd453-8762-4614-8c75-321017dc8338"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("697b6d8b-4d31-4e40-b8f2-46bc4c25e8c0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2648e7f7-34fe-4c86-99eb-f42fb0a92384"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5c19d416-b3c5-4b78-b80e-0ebdf2255d2f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e464f639-caa3-4425-867d-60acde28d6c7"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2cab1137-c04d-4c18-a1fd-d8124f22e884"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("08269d0d-a571-472b-be37-ff18235f30ef"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1823483d-ddfc-4350-a856-d2b320fc87e9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8c80626e-c979-46b5-8148-2cbec4f501d2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1f67a189-4f7a-4ff1-8041-5c84b85aa6aa"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fbac4979-75e8-4042-b5f2-adbbbe79b636"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("65594d44-edad-4d65-a3b8-a65724ad95ff"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b4ad27a0-a8a0-4240-b5ec-ea35741cf19f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("870ec304-5917-40c9-8d12-fae978878145"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6f6e106a-7b27-46fe-8adb-d21f0ad04062"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e32960f9-5a95-4c6f-be9d-85d59643bd62"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4fbb45f2-1826-4f4e-8846-a937f04fc9c6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f051c92e-c893-4148-a0c4-987382532c3b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ed96284a-ed40-4521-91c5-6d757efc9ea4"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("34e8490d-a7ac-4940-bb92-b04c5f2d2a0f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cba2d7cb-7a88-4635-b059-0bb7da52aa5a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4e0efeeb-463b-48d7-835f-4337e5f8db1d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ded75a35-1149-4831-8980-a5552b8aba39"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5376fc5a-24df-4a10-ae8d-bf4a7cb41dce"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("736c95bf-4f53-46e7-b773-ad38ec3ddd8d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a08f24a4-f5c0-426c-a415-42c7823dae7a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1bfece31-2930-4a2f-beef-be08d3bfb95b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b04a9be1-cf18-4c25-9ea7-a71db0973fd1"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6973c3f9-6578-4965-ada2-f257f0933c16"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7e191e49-0548-4943-8811-d53c3740d6ad"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b419616e-ccd8-4872-ba8d-10dc80482a85"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c0f12314-72e1-438b-b5f2-0b3aafa8ee40"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7357049c-1163-4dbf-afb4-44c77cdff207"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e7ab6e43-7142-456e-a7f4-41a98daafbd9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("38c173a0-6fb4-475e-8743-643b143cde23"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("587c3956-3c69-49da-8839-5bee906ac5bd"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7e1a8a4d-807b-4b3d-ad76-21ab2b4b5a65"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5272f534-dba6-4899-8661-5687fffef070"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b3cd2db4-f3c4-44cc-bc94-d3b39f4c4672"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f9483ce1-aa1a-409e-a618-d049642f8972"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1e82cd6b-7024-4a5e-a987-b7c6f2ff706e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("64171cfe-734a-4f02-adc4-20a51cc7526f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fd7bcaf8-2022-4cdb-8964-76d5e98a4cfb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bb8e7d27-eebe-4cd9-91ec-124397e69040"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0f85f8d1-40c9-49f7-9bbd-35aead4f4bc8"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("defa1474-5a40-4def-9759-a3130859584d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("02e29292-1019-42de-a4d8-d4f125892d51"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("172a530b-a9c9-41f7-b523-174d77ff1dd2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8a5a322d-c2b6-428b-8f78-f743cf5abfef"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cba0ecc5-2219-437c-8cfc-b989d6274261"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("aefa2578-8a39-45cd-b054-e86e15199831"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a8cd8a2e-3e24-4768-9203-70d2323a535b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e46f2b96-2913-4536-a427-b67a792cba72"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f727a037-c5a2-4745-b426-703b3e73d651"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4ef8970e-3f1b-49bd-a30d-289c4584da3b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("00531be2-4d6d-492d-8ab8-72d5e94c36f0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5b6a5647-5a28-4326-8802-1d13ecfc94b1"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("69ec8424-eab4-45a6-a503-941d5738d3f9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f6d80758-8221-41b8-9099-c6bae5611f86"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("db1dd417-9733-46e0-ab24-b174da6197e9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a04196e8-d113-433f-a672-317f7f0d4faa"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2a15a3df-317f-4f0f-abc7-360c8ec97fbb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("68b90295-945a-430e-afdc-16bb61ef5d43"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7fa5ec71-edb1-4687-a95f-a506a794626a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d3fef7f2-d827-4064-a900-9f872647eb82"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("88c098e2-d32a-40ff-9832-a08977c6adb0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e77ea9ea-20e5-4689-af38-a21489ffb9fd"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("47efe028-429d-4213-a86f-62a5c88e9cbf"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("025cf58c-b01a-4d27-ae0e-395c9b0f7e55"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("88a3c70e-cc58-4844-ae2c-4670784c2977"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("63994f0c-edb8-4ac4-9d06-3f433799dd1a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a167986f-164e-4e3b-876e-2113cba53d51"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2a470650-ecb2-488d-a3ad-ea4afe51de29"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f0882a97-6eed-4800-830e-0ad60df76b56"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d5afb82e-2001-4ef7-87b0-b0a510919f6b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("79ed7453-80b7-499f-b9fd-41d5aa0c258c"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bb0ae3a2-0dfd-41ae-898d-02fbc31636e8"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7f176330-117a-4dd2-931f-eb0543818378"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0ac9e74e-34ae-48b2-af29-0646c443cc6d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("37bda3bc-88df-45e2-9cf5-5014df0df5c0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("209149dc-eb8d-4825-9ee1-9aea3d8a8371"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("961f7973-672b-4837-b16f-d0976ccd3d14"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d0908026-efc0-4226-95b7-340e03add727"));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,786 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class DropUserPasswordHash : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordHash",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("acbf0349-4cd7-4948-8d22-9219310c7a07"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4b1e0b1a-882e-4ae7-b803-386e1e61acb2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("15d15e2a-ab44-43e0-b3bf-ccaa35e3fb91"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c2343053-018d-4026-bf14-a135479ab631"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a77e8dd8-3092-49f7-bee9-aeaaa767e134"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4083847f-a4e8-43fd-92d1-27277a039efe"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b5ca40f7-369f-4430-b5e9-765c11bf6c13"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1d42928a-bec4-4b3c-b883-a119d783a613"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8adf4b1a-b698-458f-8a4d-d959829cc56e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a01bf160-9d5f-4f34-8973-769df6805e45"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b4457af3-480c-4955-bc52-14d153491cb1"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a7f9799f-7543-4f04-9a1c-a3223798d99a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b44bce8a-2bcf-4a63-a9e8-f27d0f6c6e89"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5e75cbdd-6504-404e-a189-ec2f0bf8bfdd"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4e36584f-1037-47e0-85ed-697d1c1783f0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("eee22621-efb1-4d61-afb6-8d7fded31a16"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f587f5d1-9138-413a-aaa1-7dd56dcc981d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0bda014d-3942-4367-9293-6cbde6ac39a5"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a88ddd26-e0fa-4a13-8696-882af90fb4e4"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bd2a1844-8506-4f0b-bb0e-f20325d87bc0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("048ab71b-72d3-44b8-aea8-b05b4596d8bf"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("dbebf109-7413-425e-aaa8-5f58d2513d23"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1316245a-b4e0-4657-bdbf-8d8e257b26f9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("29bbdcca-19e6-4888-b43a-15cca7e3b4d2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("96796f8a-ce0a-47d7-9ba0-c1230bc588bb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("91994dc9-b18c-43d4-8cf1-47fe3f81ce7c"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("71270de2-8615-4084-a379-11069d0ab05b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5f974740-5e83-4483-9a93-8db1d62a7bb0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2faed272-d596-44c7-a131-eb78d7fcc72f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("505fd8fb-3d1d-4ce0-8cf3-010e828a801b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("71ce7b4d-bff6-4ab1-97d4-1c11ae17f05e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7fcc357a-a68e-4966-bddb-3dfd02223ffa"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e77ec892-1a69-45d2-a9f5-11fd92b07b96"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a6b56c75-c110-4122-9ecc-65145bed96a1"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("723bdc97-c6da-4950-adf3-77bee7e97405"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bf074feb-9bda-4244-8372-1abe67706060"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ed4592b7-e4a6-40bb-b846-6f0f42fedb0e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0428f07f-2a19-4cab-a61e-013356607a3e"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cc6396f7-7a64-4af9-9e66-7ca9a642f615"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("17f53c09-0ff5-4491-86a8-9725b4dbc7cc"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7731cbca-d29e-41d0-85d1-7016b2a2f26f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c60ed0dd-eedf-4f15-accc-5913c182dd50"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4bffcc65-ec6d-4b8b-8613-b872bedf8399"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b6817e86-b3bf-4e87-882a-128dfa11c3dc"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a02e4ff9-b950-400b-b312-e0a59c5a6cf0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3563d851-8dda-4d6c-b33a-cb16a3538a51"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bcd5a22a-0d6d-4fe6-a9d9-c179188f6a4c"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("08376f57-d92c-411f-bcb9-d88bcb646e51"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1dbe1273-2cc6-4d0e-b7d2-1c1e5b620935"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3927638d-2b9b-463f-907e-ec4ae5e30ad4"));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PasswordHash",
|
||||
table: "Users",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000001"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2933abc2-b472-4870-8af7-a54a3adc4163"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000002"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d599d707-9645-4aad-8277-b492b2284eca"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000003"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("912132ef-5996-4a7f-acdf-e70a8aebec61"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000004"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("3193b6b5-8656-41a5-88f1-264cda89dc38"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000005"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("33a3bace-319c-4394-a8ca-66f4983e8a65"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000006"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("d67d727b-6bc6-437e-b52a-69bc6a78a009"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000007"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("03c210fa-f841-4262-96a8-d167bcca84de"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000008"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4949daa6-2136-400a-8b92-a0650ebd433d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000009"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("abd013d2-5d26-4e08-ab9c-506a8bd8a4fc"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000010"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f6ea9dbf-42ec-4fdf-b61a-5359f302e3de"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000011"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1a6d4dfe-32f5-4860-8c0c-3109f6dbdc56"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000012"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6387f234-eb63-43f1-8b20-1262cc646ef7"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000013"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("bf6e1071-4c1e-45ba-ac90-54935832ab33"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000014"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2e009c83-d9be-41b1-9cfb-a720671f9531"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000015"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("0a1c09c4-4851-4c03-a728-be2be77425cb"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000016"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6d5cfd42-9ad3-4c6a-81c1-27c92fa70746"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000017"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cdd856de-60ba-431a-9c18-59368cf5f325"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000018"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("28ecd453-8762-4614-8c75-321017dc8338"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000019"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("697b6d8b-4d31-4e40-b8f2-46bc4c25e8c0"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000020"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2648e7f7-34fe-4c86-99eb-f42fb0a92384"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000021"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5c19d416-b3c5-4b78-b80e-0ebdf2255d2f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000022"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e464f639-caa3-4425-867d-60acde28d6c7"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000023"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("2cab1137-c04d-4c18-a1fd-d8124f22e884"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000024"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("08269d0d-a571-472b-be37-ff18235f30ef"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000025"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1823483d-ddfc-4350-a856-d2b320fc87e9"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000026"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("8c80626e-c979-46b5-8148-2cbec4f501d2"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000027"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1f67a189-4f7a-4ff1-8041-5c84b85aa6aa"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000028"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("fbac4979-75e8-4042-b5f2-adbbbe79b636"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000029"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("65594d44-edad-4d65-a3b8-a65724ad95ff"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000030"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b4ad27a0-a8a0-4240-b5ec-ea35741cf19f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000031"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("870ec304-5917-40c9-8d12-fae978878145"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000032"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6f6e106a-7b27-46fe-8adb-d21f0ad04062"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000033"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("e32960f9-5a95-4c6f-be9d-85d59643bd62"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000034"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4fbb45f2-1826-4f4e-8846-a937f04fc9c6"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000035"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("f051c92e-c893-4148-a0c4-987382532c3b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000036"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ed96284a-ed40-4521-91c5-6d757efc9ea4"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000037"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("34e8490d-a7ac-4940-bb92-b04c5f2d2a0f"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000038"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("cba2d7cb-7a88-4635-b059-0bb7da52aa5a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000039"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("4e0efeeb-463b-48d7-835f-4337e5f8db1d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000040"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("ded75a35-1149-4831-8980-a5552b8aba39"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000041"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("5376fc5a-24df-4a10-ae8d-bf4a7cb41dce"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000042"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("736c95bf-4f53-46e7-b773-ad38ec3ddd8d"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000043"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("a08f24a4-f5c0-426c-a415-42c7823dae7a"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000044"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("1bfece31-2930-4a2f-beef-be08d3bfb95b"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000045"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b04a9be1-cf18-4c25-9ea7-a71db0973fd1"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000046"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("6973c3f9-6578-4965-ada2-f257f0933c16"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000047"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7e191e49-0548-4943-8811-d53c3740d6ad"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000048"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("b419616e-ccd8-4872-ba8d-10dc80482a85"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000049"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("c0f12314-72e1-438b-b5f2-0b3aafa8ee40"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "RolePermissions",
|
||||
keyColumns: new[] { "FK_PermissionId", "FK_RoleId" },
|
||||
keyValues: new object[] { new Guid("20000000-0000-0000-0000-000000000050"), new Guid("10000000-0000-0000-0000-000000000007") },
|
||||
column: "Id",
|
||||
value: new Guid("7357049c-1163-4dbf-afb4-44c77cdff207"));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("00000001-0000-0000-0000-000000000001"),
|
||||
column: "PasswordHash",
|
||||
value: "N/A");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000001"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000002"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000003"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000004"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000005"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("29000000-0000-0000-0000-000000000006"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Users",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("70000000-0000-0000-0000-000000000001"),
|
||||
column: "PasswordHash",
|
||||
value: "AQAAAAIAAYagAAAAEKGnq/U4j6uM9g5mFkxbUE8WU/AhnSNiwrKCiPAqGnzNcaMgZAF5Zal/rJUUYPZPpg==");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user