| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.ComponentModel.DataAnnotations;
- namespace Domain.Entities.Page.Popup
- {
- public class PopupPosition
- {
- public virtual List<Popup> Popups { get; private set; } = [];
- [Key]
- public int ID { get; private set; }
- public string Code { get; private set; } = default!;
- public string Subject { get; private set; } = default!;
- public bool IsActive { get; private set; } = false;
- public DateTime? UpdatedAt { get; private set; }
- public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
- private PopupPosition() { }
- private PopupPosition(string code, string subject, bool isActive)
- {
- if (string.IsNullOrWhiteSpace(code))
- {
- throw new ArgumentException("Code is required.", nameof(code));
- }
- if (code.Length > 30)
- {
- throw new ArgumentOutOfRangeException(nameof(code));
- }
- if (string.IsNullOrWhiteSpace(subject))
- {
- throw new ArgumentException("Subject is required.", nameof(subject));
- }
- if (subject.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(subject));
- }
- Code = code;
- Subject = subject;
- IsActive = isActive;
- }
- public static PopupPosition Create(string code, string subject, bool isActive = false)
- {
- return new(code, subject, isActive);
- }
- public void Update(string subject, bool isActive)
- {
- if (string.IsNullOrWhiteSpace(subject))
- {
- throw new ArgumentException("Subject is required.", nameof(subject));
- }
- if (subject.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(subject));
- }
- Subject = subject;
- IsActive = isActive;
- UpdatedAt = DateTime.UtcNow;
- }
- }
- }
|