﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NextGen.Core.EntityFramework
{
    public class EntityMap<T> : EntityTypeConfiguration<T> where T : class, IEntity
    {
        public EntityMap()
        {
            ToTable(typeof(T).Name);

            HasKey(p => p.Id);
        }
    }

    public class TableEntityMap<T> : EntityMap<T> where T : class, IEntity, ITableEntity
    {
        public TableEntityMap()
        {
            Property(p => p.CreateBy).IsRequired();
        }
    }

    public class DefinitionTableEntityMap<T> : TableEntityMap<T> where T : class, IEntity, IDefinitionTableEntity
    {
        public DefinitionTableEntityMap()
        {
            Property(p => p.Name).IsRequired().HasMaxLength(100);
            Property(p => p.Description).HasMaxLength(255);

            Property(p => p.CreateBy).IsRequired();
        }
    }
}
