| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- namespace Domain.Entities.Page
- {
- public class Popup
- {
- public int ID { get; private set; }
- public string Subject { get; private set; } = default!;
- public string? Content { get; private set; }
- public string? Link { get; private set; }
- public DateTime? StartAt { get; private set; }
- public DateTime? EndAt { get; private set; }
- public short Order { get; private set; } = 0;
- public bool IsActive { get; private set; } = false;
- public DateTime? UpdatedAt { get; private set; }
- public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
- private Popup() { }
- private Popup(string subject, string? content, string? link, DateTime? startAt, DateTime? endAt, short order, bool isActive)
- {
- if (string.IsNullOrWhiteSpace(subject))
- {
- throw new ArgumentException("Subject is required.", nameof(subject));
- }
- if (subject.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(subject));
- }
- if (order < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(order));
- }
- Subject = subject;
- Content = content;
- Link = link;
- StartAt = startAt;
- EndAt = endAt;
- Order = order;
- IsActive = isActive;
- }
- public static Popup Create(string subject, string? content = null, string? link = null, DateTime? startAt = null, DateTime? endAt = null, short order = 0, bool isActive = false)
- {
- return new(subject, content, link, startAt, endAt, order, isActive);
- }
- public void Update(string subject, string? content, string? link, DateTime? startAt, DateTime? endAt, short order, bool isActive)
- {
- if (string.IsNullOrWhiteSpace(subject))
- {
- throw new ArgumentException("Subject is required.", nameof(subject));
- }
- if (subject.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(subject));
- }
- if (order < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(order));
- }
- Subject = subject;
- Content = content;
- Link = link;
- StartAt = startAt;
- EndAt = endAt;
- Order = order;
- IsActive = isActive;
- UpdatedAt = DateTime.UtcNow;
- }
- public void SetContent(string? content)
- {
- Content = content;
- UpdatedAt = DateTime.UtcNow;
- }
- }
- }
|