/
d.alekseev
/
SmartMenuBot
Обзор
Документация
Войти
/
d.alekseev
/
SmartMenuBot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ConsoleBot/Core/Entities/Notification.cs
61 строка
2 KB
d.alekseev
feat: нотификации и фоновые задачи доставки уведомлений
26 фев 2026, 10:55
26 фев 2026, 10:55
4338916
Код
Авторство
О чём код?
namespace SmartMenuBot.Core.Entities { public class Notification { public Guid Id { get; } public ToDoUser User { get; } public string Type { get; } public string Text { get; } public DateTime ScheduledAt { get; } public bool IsNotified { get; private set; } public DateTime? NotifiedAt { get; private set; } public Notification(ToDoUser user, string type, string text, DateTime scheduledAt) : this(Guid.NewGuid(), user, type, text, scheduledAt, false, null) { } private Notification( Guid id, ToDoUser user, string type, string text, DateTime scheduledAt, bool isNotified, DateTime? notifiedAt) { if (id == Guid.Empty) throw new ArgumentException("Поле Id не может быть пустым GUID", nameof(id)); if (string.IsNullOrWhiteSpace(type)) throw new ArgumentException("Поле Type не может быть пустым", nameof(type)); if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Поле Text не может быть пустым", nameof(text)); Id = id; User = user ?? throw new ArgumentNullException(nameof(user)); Type = type; Text = text; ScheduledAt = scheduledAt; IsNotified = isNotified; NotifiedAt = notifiedAt; } public static Notification Restore( Guid id, ToDoUser user, string type, string text, DateTime scheduledAt, bool isNotified, DateTime? notifiedAt) { return new Notification(id, user, type, text, scheduledAt, isNotified, notifiedAt); } public void MarkNotified(DateTime notifiedAt) { IsNotified = true; NotifiedAt = notifiedAt; } } }