using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Domain.Entities.Members;

namespace Domain.Entities.Forum.Boards
{
    [Table(nameof(BoardManager))]
    [Index(nameof(BoardID))]
    [Index(nameof(MemberID))]
    [Index(nameof(BoardID), nameof(MemberID))]
    public class BoardManager
    {
        [ForeignKey(nameof(BoardID))]
        public virtual Board Board { get; set; } = null!;

        [ForeignKey(nameof(MemberID))]
        public virtual Member Member { get; set; } = null!;

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

        [DisplayName("게시판 ID")]
        [Comment("게시판 ID")]
        [Required(ErrorMessage = "{0}는 필수입니다.")]
        public int BoardID { get; set; }

        [DisplayName("관리자 ID")]
        [Comment("관리자 ID")]
        [Required(ErrorMessage = "{0}는 필수입니다.")]
        public string MemberID { get; set; } = default!;

        [DisplayName("수정 권한")]
        [Comment("수정 권한")]
        public bool CanEdit { get; set; } = false;

        [DisplayName("삭제 권한")]
        [Comment("삭제 권한")]
        public bool CanDelete { get; set; } = false;

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

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