feat(ministry): add Ministry entity, seed (10), and read endpoint

This commit is contained in:
Chris Chen
2026-05-29 18:03:28 -07:00
parent 50e518095e
commit f6f06d841c
9 changed files with 150 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using ROLAC.API.Data;
using ROLAC.API.DTOs.Ministry;
namespace ROLAC.API.Services;
public class MinistryService : IMinistryService
{
private readonly AppDbContext _db;
public MinistryService(AppDbContext db) => _db = db;
public async Task<List<MinistryDto>> GetAllAsync(bool includeInactive)
{
var query = _db.Ministries.AsNoTracking().AsQueryable();
if (!includeInactive) query = query.Where(m => m.IsActive);
return await query
.OrderBy(m => m.SortOrder).ThenBy(m => m.Name_en)
.Select(m => new MinistryDto
{
Id = m.Id, Name_en = m.Name_en, Name_zh = m.Name_zh,
SortOrder = m.SortOrder, IsActive = m.IsActive,
})
.ToListAsync();
}
}