ref: project structure
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using mws.backend.dotnet.application.Common;
|
||||
using mws.backend.dotnet.application.Common.Repositories;
|
||||
using mws.backend.dotnet.domain.MasterData;
|
||||
|
||||
namespace mws.backend.dotnet.infrastructure.Persistence.Repositories;
|
||||
|
||||
public class MasterDataRepository(AppDbContext db) : RepositoryBase<MasterDataEntry>(db), IMasterDataRepository
|
||||
{
|
||||
public Task<PagedResult<MasterDataEntry>> GetAllAsync(string? group, int page, int pageSize, CancellationToken ct = default) =>
|
||||
Set.Where(m => group == null || m.Group == group)
|
||||
.OrderBy(m => m.Group).ThenBy(m => m.SortOrder).ThenBy(m => m.Label)
|
||||
.ToPagedResultAsync(page, pageSize, ct);
|
||||
|
||||
public Task<List<MasterDataEntry>> GetActiveByGroupAsync(string group, CancellationToken ct = default) =>
|
||||
Set.Where(m => m.Group == group && m.IsActive)
|
||||
.OrderBy(m => m.SortOrder).ThenBy(m => m.Label)
|
||||
.ToListAsync(ct);
|
||||
|
||||
public Task<MasterDataEntry?> GetByIdAsync(Guid id, CancellationToken ct = default) =>
|
||||
Set.FirstOrDefaultAsync(m => m.Id == id, ct);
|
||||
|
||||
public Task<bool> ExistsAsync(string group, string value, Guid? excludeId, CancellationToken ct = default) =>
|
||||
Set.AnyAsync(m => m.Group == group && m.Value == value && (excludeId == null || m.Id != excludeId), ct);
|
||||
}
|
||||
Reference in New Issue
Block a user