29 lines
928 B
C#
29 lines
928 B
C#
using Backend.Data;
|
|
using Backend.Domain;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Backend.Repositories;
|
|
|
|
public sealed class RiskFlagRepository(AwardsDbContext dbContext) : IRiskFlagRepository
|
|
{
|
|
public Task<bool> ExistsOpenRecentAsync(
|
|
int? seasonId,
|
|
string? twitchUserId,
|
|
string source,
|
|
string type,
|
|
string clientIp,
|
|
DateTimeOffset threshold,
|
|
CancellationToken cancellationToken = default) =>
|
|
dbContext.RiskFlags.AnyAsync(
|
|
item => item.Status == "open"
|
|
&& item.Source == source
|
|
&& item.Type == type
|
|
&& item.TwitchUserId == twitchUserId
|
|
&& item.CreatedFromIp == clientIp
|
|
&& item.SeasonId == seasonId
|
|
&& item.CreatedAt >= threshold,
|
|
cancellationToken);
|
|
|
|
public void Add(RiskFlag riskFlag) => dbContext.RiskFlags.Add(riskFlag);
|
|
}
|