using Microsoft.EntityFrameworkCore; using Fengling.RiskControl.Domain.Aggregates.RiskAlerts; using Fengling.RiskControl.Domain.Repositories; namespace Fengling.RiskControl.Infrastructure.Repositories; public class RiskAlertRepository : IRiskAlertRepository { private readonly RiskControlDbContext _context; public RiskAlertRepository(RiskControlDbContext context) { _context = context; } public async Task GetByIdAsync(long id) { return await _context.RiskAlerts.FindAsync(id); } public async Task> GetByMemberIdAsync(long memberId) { return await _context.RiskAlerts .Where(a => a.MemberId == memberId) .ToListAsync(); } public async Task> GetPendingAlertsAsync() { return await _context.RiskAlerts .Where(a => a.Status == RiskAlertStatus.Pending) .OrderByDescending(a => a.Priority) .ToListAsync(); } public async Task> GetAlertsByPriorityAsync(RiskAlertPriority priority) { return await _context.RiskAlerts .Where(a => a.Priority == priority) .ToListAsync(); } public async Task AddAsync(RiskAlert alert) { await _context.RiskAlerts.AddAsync(alert); } public async Task UpdateAsync(RiskAlert alert) { _context.RiskAlerts.Update(alert); await Task.CompletedTask; } public async Task DeleteAsync(RiskAlert alert) { _context.RiskAlerts.Remove(alert); await Task.CompletedTask; } }