/
AMachine
/
MMDB_Backend
Обзор
Документация
Войти
/
AMachine
/
MMDB_Backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
MMDB.Data/Extensions/NotesFilter.cs
53 строки
3 KB
AssaultMachine
готово короче
22 май 2025, 17:37
22 май 2025, 17:37
e81a9bb
Код
Авторство
О чём код?
using MMDB.Core.FilterParameters; using MMDB.Data.Entities.SS13; namespace MMDB.Data.Extensions; public static class NotesFilter { public static IQueryable<MessageEntity> Filter(this IQueryable<MessageEntity> notes, NoteParameters filter) { if (filter.Id.HasValue) notes = notes.Where(m => m.Id == filter.Id.Value); if (!string.IsNullOrEmpty(filter.Type)) notes = notes.Where(note => note.Type.Contains(filter.Type)); if (!string.IsNullOrEmpty(filter.TargetCkey)) notes = notes.Where(note => note.Targetckey.Contains(filter.TargetCkey)); if (!string.IsNullOrEmpty(filter.AdminCkey)) notes = notes.Where(note => note.Adminckey.Contains(filter.AdminCkey)); if (filter.MinTimestamp.HasValue) notes = notes.Where(note => note.Timestamp >= filter.MinTimestamp.Value); if (filter.MaxTimestamp.HasValue) notes = notes.Where(note => note.Timestamp <= filter.MaxTimestamp.Value); if (!string.IsNullOrEmpty(filter.Server)) notes = notes.Where(note => note.Server.Contains(filter.Server)); if (filter.ServerIp.HasValue) notes = notes.Where(note => note.ServerIp == filter.ServerIp); if (filter.ServerPort.HasValue) notes = notes.Where(note => note.ServerPort == filter.ServerPort); if (filter.MinRoundId.HasValue) notes = notes.Where(note => note.RoundId >= filter.MinRoundId.Value); if (filter.MaxRoundId.HasValue) notes = notes.Where(note => note.RoundId <= filter.MaxRoundId.Value); if (filter.IsSecret.HasValue) notes = notes.Where(note => note.Secret == (filter.IsSecret.Value ? 1 : 0)); if (filter.IsDeleted.HasValue) notes = notes.Where(note => note.Deleted == (filter.IsDeleted.Value ? 1 : 0)); if (!string.IsNullOrEmpty(filter.Severity)) notes = notes.Where(note => note.Severity == filter.Severity); if (filter.MinExpireTimestamp.HasValue) notes = notes.Where(note => note.ExpireTimestamp >= filter.MinExpireTimestamp.Value); if (filter.MaxExpireTimestamp.HasValue) notes = notes.Where(note => note.ExpireTimestamp <= filter.MaxExpireTimestamp.Value); if (filter.MinPlaytime.HasValue) notes = notes.Where(note => note.Playtime >= filter.MinPlaytime.Value); if (filter.MaxPlaytime.HasValue) notes = notes.Where(note => note.Playtime <= filter.MaxPlaytime.Value); if (!string.IsNullOrEmpty(filter.LastEditor)) notes = notes.Where(note => note.Lasteditor.Contains(filter.LastEditor)); if (!string.IsNullOrEmpty(filter.DeletedCkey)) notes = notes.Where(note => note.DeletedCkey.Contains(filter.DeletedCkey)); return notes.Sort(filter); } }