| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- namespace Domain.Entities.Page.Faq
- {
- public class FaqItem
- {
- public virtual FaqCategory FaqCategory { get; private set; } = null!;
- public int ID { get; private set; }
- public int CategoryID { get; private set; }
- public string Question { get; private set; } = default!;
- public string? Answer { 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 FaqItem() { }
- private FaqItem(int categoryID, string question, string? answer, short order, bool isActive)
- {
- if (categoryID <= 0)
- {
- throw new ArgumentOutOfRangeException(nameof(categoryID));
- }
- if (string.IsNullOrWhiteSpace(question))
- {
- throw new ArgumentException("Question is required.", nameof(question));
- }
- if (question.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(question));
- }
- if (order < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(order));
- }
- CategoryID = categoryID;
- Question = question;
- Answer = answer;
- Order = order;
- IsActive = isActive;
- }
- public static FaqItem Create(int categoryID, string question, string? answer = null, short order = 0, bool isActive = false)
- {
- return new(categoryID, question, answer, order, isActive);
- }
- public void Update(int categoryID, string question, string? answer, short order, bool isActive)
- {
- if (categoryID <= 0)
- {
- throw new ArgumentOutOfRangeException(nameof(categoryID));
- }
- if (string.IsNullOrWhiteSpace(question))
- {
- throw new ArgumentException("Question is required.", nameof(question));
- }
- if (question.Length > 255)
- {
- throw new ArgumentOutOfRangeException(nameof(question));
- }
- if (order < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(order));
- }
- CategoryID = categoryID;
- Question = question;
- Answer = answer;
- Order = order;
- IsActive = isActive;
- UpdatedAt = DateTime.UtcNow;
- }
- public void SetContent(string? answer)
- {
- Answer = answer;
- UpdatedAt = DateTime.UtcNow;
- }
- }
- }
|