Add region code
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user