public static IQueryable <InfractionEntity> FilterBy(this IQueryable <InfractionEntity> query, InfractionSearchCriteria criteria) => query .FilterBy( x => x.Id == criteria.Id, criteria?.Id != null) .FilterBy( x => x.GuildId == criteria.GuildId, criteria?.GuildId != null) .FilterBy( x => criteria.Types.Contains(x.Type), criteria?.Types?.Any() ?? false) .FilterBy( x => x.Subject.Nickname.ToUpper().Contains(criteria.Subject.ToUpper()) || x.Subject.User.Username.ToUpper().Contains(criteria.Subject.ToUpper()), !string.IsNullOrWhiteSpace(criteria?.Subject)) .FilterBy( x => x.SubjectId == criteria.SubjectId, criteria?.SubjectId != null) .FilterBy( x => x.CreateAction.Created >= criteria.CreatedRange.Value.From, criteria?.CreatedRange?.From != null) .FilterBy( x => x.CreateAction.Created <= criteria.CreatedRange.Value.To, criteria?.CreatedRange?.To != null) .FilterBy( x => x.CreateAction.CreatedBy.Nickname.ToUpper().Contains(criteria.Creator.ToUpper()) || x.CreateAction.CreatedBy.User.Username.ToUpper().Contains(criteria.Creator.ToUpper()), !string.IsNullOrWhiteSpace(criteria?.Creator)) .FilterBy( x => x.CreateAction.CreatedById == criteria.CreatedById, criteria?.CreatedById != null) .FilterBy( x => (x.RescindActionId != null) == criteria.IsRescinded, criteria?.IsRescinded != null) .FilterBy( x => (x.DeleteActionId != null) == criteria.IsDeleted, criteria?.IsDeleted != null) .FilterBy( x => (x.CreateAction.Created + x.Duration) >= criteria.ExpiresRange.Value.From, criteria?.ExpiresRange?.From != null) .FilterBy( x => (x.CreateAction.Created + x.Duration) <= criteria.ExpiresRange.Value.To, criteria?.ExpiresRange?.To != null);
public static IQueryable <InfractionEntity> FilterBy(this IQueryable <InfractionEntity> query, InfractionSearchCriteria criteria) => query .FilterBy( x => x.Id == criteria.Id, criteria?.Id != null) .FilterBy(
public static IQueryable <InfractionEntity> FilterBy(this IQueryable <InfractionEntity> query, InfractionSearchCriteria criteria) => query .FilterBy( x => x.GuildId == criteria.GuildId, criteria?.GuildId != null) .FilterBy( x => criteria.Types.Contains(x.Type), criteria?.Types?.Any() ?? false) .FilterBy( x => x.SubjectId == criteria.SubjectId, criteria?.SubjectId != null) .FilterBy( x => x.CreateAction.Created >= criteria.CreatedRange.Value.From, criteria?.CreatedRange?.From != null) .FilterBy( x => x.CreateAction.Created <= criteria.CreatedRange.Value.To, criteria?.CreatedRange?.To != null) .FilterBy( x => x.CreateAction.CreatedById == criteria.CreatedById, criteria?.CreatedById != null) .FilterBy( x => (x.RescindActionId != null) == criteria.IsRescinded, criteria?.IsRescinded != null) .FilterBy( x => (x.DeleteActionId != null) == criteria.IsDeleted, criteria?.IsDeleted != null) .FilterBy( x => (x.CreateAction.Created + x.Duration) >= criteria.ExpiresRange.Value.From, criteria?.ExpiresRange?.From != null) .FilterBy( x => (x.CreateAction.Created + x.Duration) <= criteria.ExpiresRange.Value.To, criteria?.ExpiresRange?.To != null);