using EntityFrameworkCore.Projectables;
using IRaCIS.Core.Domain.Share;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IRaCIS.Core.Domain.Models
{
    [Table("Dictionary")]
    public partial class Dictionary : Entity, IAuditUpdate, IAuditAdd
    {
        public string ChildGroup { get; set; }

        public int ChildCodeEnum { get; set; }


        public DicDataTypeEnum DataTypeEnum { get; set; }


        [Column("Value")]
        public string Value { get; set; } = string.Empty;

        [Column("ValueCN")]
        public string ValueCN { get; set; } = string.Empty;


        [StringLength(512)]
        public string Description { get; set; } = string.Empty;

        public int ShowOrder { get; set; }


        public Guid UpdateUserId { get; set; }
        public DateTime UpdateTime { get; set; }
        public Guid CreateUserId { get; set; }
        public DateTime CreateTime { get; set; }


        public string Code { get; set; }

        public Guid? ParentId { get; set; }

        public bool IsEnable { get; set; }

        public Guid? ConfigTypeId { get; set; }

        [JsonIgnore]
        [ForeignKey("ConfigTypeId")]
        public Dictionary ConfigDictionary { get; set; }

        [JsonIgnore]
        [ForeignKey("ParentId")]
        public Dictionary Parent { get; set; }
        [JsonIgnore]
        public List<Dictionary> ChildList { get; set; } = new List<Dictionary>();


        [NotMapped]
        public string MappedValue { get; set; }


        [Projectable]
        public  string TranslateValue( string value, string valueCN,bool isCN) => isCN?valueCN:value;


    }
}
