using APT.Infrastructure.EF.Map;
using APT.BaseData.Domain.Entities.FM;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace APT.BaseData.Data.Mapping.FM
{
	public class FMWorkStageMap : APTEntityBaseMap<T_FM_WORKSTAGE>
	{
		public override void Configure(EntityTypeBuilder<T_FM_WORKSTAGE> builder)
		{
			base.Configure(builder);
			builder.Property(t => t.CODE).HasMaxLength(100);
			builder.Property(t => t.NAME).HasMaxLength(300);
            builder.Property(t => t.NAME_ACRONYM).HasMaxLength(600);
            builder.Property(t => t.BAR_CODE).HasMaxLength(300);
			builder.Property(t => t.STATUS_DESC).HasMaxLength(500);
            builder.Property(t => t.EXT_NAME).HasMaxLength(50);
            builder.Ignore(t => t.OccRadio);
			builder.HasOne(t => t.Nav_Procedure).WithMany().HasForeignKey(t => t.PROCEDURE_ID);

			builder.HasOne(t => t.Nav_Department).WithMany().HasForeignKey(t => t.DEPARTMENT_ID);

			//builder.HasOne(t => t.Nav_Work).WithMany().HasForeignKey(t => t.WORK_ID);

			builder.HasOne(t => t.Nav_WorkStage).WithMany().HasForeignKey(t => t.WORKSTAGE_ID);

			builder.HasMany(t => t.Nav_Attrs).WithOne().HasForeignKey(t => t.WORKSTAGE_ID);
            builder.HasIndex(o => o.CODE);
            builder.HasIndex(o => o.NAME);
            builder.HasIndex(o => o.CREATE_TIME);
        } 
	}
}
