Add region code

This commit is contained in:
2026-10-06 15:09:22 +05:30
parent edb5fddc3a
commit c52ecfdebc
11 changed files with 251 additions and 10 deletions
@@ -11,6 +11,13 @@ public class RegionRepository(AppDBContext context) : IRegionRepository
public async Task<List<Models.Region>> GetAllAsync() =>
await context.Regions.ToListAsync();
// Includes soft-deleted regions: the unique index on Code doesn't know about IsActive.
public async Task<List<string>> GetAllCodesAsync() =>
await context.Regions.Select(r => r.Code).ToListAsync();
public async Task<bool> CodeExistsAsync(string code, Guid? excludeId = null) =>
await context.Regions.AnyAsync(r => r.Code == code && (excludeId == null || r.Id != excludeId));
public async Task AddAsync(Models.Region entity) =>
await context.Regions.AddAsync(entity);