using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace bitforum.Models.Page.Faq
{
    [Table("FaqItem")]
    [Index(nameof(Order), Name = "IX_FaqItem_Order")]
    [Index(nameof(IsActive), Name = "IX_FaqItem_IsActive")]
    public class FaqItem
    {
        [ValidateNever]
        [ForeignKey("CategoryID")]
        public virtual FaqCategory FaqCategory { get; set; } = null!;

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DisplayName("PK")]
        [Comment("PK")]
        public int ID { get; set; }

        [Required]
        [DisplayName("분류 ID")]
        [Comment("분류 ID")]
        public int CategoryID { get; set; }

        [Required]
        [DisplayName("질문")]
        [Comment("질문")]
        [DataType(DataType.Text)]
        [StringLength(255)]
        public string Question { get; set; } = null!;

        [DisplayName("답변")]
        [Comment("답변")]
        [DataType(DataType.Html)]
        public string? Answer { get; set; } = null;

        [Required]
        [DisplayName("순서")]
        [Comment("순서")]
        public int Order { get; set; } = 0;

        [Required]
        [DisplayName("사용 여부")]
        [Comment("사용 여부")]
        public bool IsActive { get; set; } = false;

        [DisplayName("조회 수")]
        [Comment("조회 수")]
        public int Views { get; set; } = 0;

        [DisplayName("수정 일시")]
        [Comment("수정 일시")]
        [DataType(DataType.DateTime)]
        public DateTime? UpdatedAt { get; set; } = null;

        [DisplayName("등록 일시")]
        [Comment("등록 일시")]
        [DataType(DataType.DateTime)]
        public DateTime CreatedAt { get; set; }
    }
}
