1cb7a8ca4a
Phase 3 — eliminated ApplicationDbContext from all non-exempt controllers, routing all data access through IUnitOfWork. Added IPlainRepository<T> for the four platform entities (Announcement, BannedIp, DashboardTip, ReleaseNote) that intentionally don't extend BaseEntity and therefore can't use the constrained IRepository<T>. Added permanent-exception comments to the 18 controllers that legitimately retain direct DbContext access (Identity infra, cross-tenant platform ops, bulk streaming exports). Phase 4 — added EnforceDataAccessArchitecture() to Program.cs, a startup gate that reflects over every Controller subclass and throws at boot if any non-exempt controller injects ApplicationDbContext. The app cannot start with a violation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using System.Linq.Expressions;
|
|
|
|
namespace PowderCoating.Core.Interfaces;
|
|
|
|
/// <summary>
|
|
/// Lightweight repository interface for platform-level entities that do not inherit
|
|
/// <see cref="PowderCoating.Core.Entities.BaseEntity"/> (e.g. Announcement, BannedIp,
|
|
/// DashboardTip, ReleaseNote). These entities have no CompanyId, no IsDeleted, and no
|
|
/// soft-delete semantics — so the full IRepository<T> contract (SoftDeleteAsync,
|
|
/// ignoreQueryFilters) does not apply.
|
|
/// </summary>
|
|
/// <typeparam name="T">Any EF-mapped class (does not need to inherit BaseEntity).</typeparam>
|
|
public interface IPlainRepository<T> where T : class
|
|
{
|
|
Task<T?> GetByIdAsync(int id);
|
|
Task<IEnumerable<T>> GetAllAsync();
|
|
Task<IEnumerable<T>> FindAsync(Expression<Func<T, bool>> predicate);
|
|
Task<T?> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
|
Task<bool> AnyAsync(Expression<Func<T, bool>> predicate);
|
|
Task<int> CountAsync(Expression<Func<T, bool>>? predicate = null);
|
|
|
|
Task<T> AddAsync(T entity);
|
|
Task<IEnumerable<T>> AddRangeAsync(IEnumerable<T> entities);
|
|
|
|
Task UpdateAsync(T entity);
|
|
|
|
Task DeleteAsync(T entity);
|
|
Task DeleteAsync(int id);
|
|
}
|