Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Add IAdminDataScope<TEntity> abstraction (ARCH-001 Phase 1)

KrzysztofPajak7b404b92fa08
diff --git a/src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs b/src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs
new file mode 100644
index 000000000..e64f6b381
--- /dev/null
+++ b/src/Web/Grand.Web.AdminShared/Interfaces/IAdminDataScope.cs
@@ -0,0 +1,25 @@
+#nullable enable
+
+namespace Grand.Web.AdminShared.Interfaces;
+
+/// <summary>
+/// Per-host data-access strategy for an admin-area entity. Implemented once per host
+/// (Admin/Store/Vendor) and injected into shared AdminShared controllers/services so
+/// scope logic lives in one place instead of being duplicated per host.
+/// </summary>
+public interface IAdminDataScope<TEntity>
+{
+ /// <summary>Whether the current user may access this specific, already-loaded entity.</summary>
+ Task<bool> HasAccess(TEntity entity);
+
+ /// <summary>Narrows a query to the entities the current user may see. No-op for global (Admin) scope.</summary>
+ IQueryable<TEntity> ApplyScope(IQueryable<TEntity> query);
+
+ /// <summary>Store id to default onto new/edited entities. Null when the host has no store concept
+ /// (Admin: global, no default; Vendor: not store-scoped at all).</summary>
+ string? DefaultStoreId { get; }
+
+ /// <summary>Prefix used to build host-specific localization keys, e.g. "Admin", "Vendor". Store
+ /// currently has no distinct resource set and uses "Admin" (see Task 6).</summary>
+ string ResourceKeyPrefix { get; }
+}