using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;

namespace bitforum.Models.Page
{
    [Index(nameof(Code), Name = "IX_Document_Code", IsUnique = true)]
    public class Document
    {
        [Key]
        public int ID { get; set; }

        public bool IsDisplay { get; set; } = false;

        [DataType(DataType.Text)]
        [MaxLength(30)]
        [RegularExpression(@"^[a-zA-Z0-9]+$", ErrorMessage = "Code는 영문 및 숫자로만 구성되어야 합니다.")]
        public string Code { get; set; }

        [DataType(DataType.Text)]
        [MaxLength(120)]
        public string Subject { get; set; }

        [DataType(DataType.Html)]
        public string? Content { get; set; } = null;

        public int Views { get; set; } = 0;

        [DataType(DataType.DateTime)]
        public DateTime? UpdatedAt { get; set; } = null;

        [DataType(DataType.DateTime)]
        public DateTime? CreatedAt { get; set; } = null;
    }
}
