using GreenTree.Strohrmann.ERP.Core.Domain.Business;
using GreenTree.Strohrmann.ERP.Domain.Model.Shared;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Text;

namespace GreenTree.Strohrmann.ERP.Domain.Model.Business
{
    public class SupplierMapping : TrackedEntityMapping<Supplier>
    {
        public override void Configure(EntityTypeBuilder<Supplier> builder)
        {
            base.Configure(builder);

            builder.ToTable("Suppliers");

            builder.HasKey(u => u.Id);

            builder.Property(u => u.Id)
                .ValueGeneratedOnAdd();

            builder.Property(u => u.Name)
                .IsRequired();

            builder.Property(u => u.Description)
                .IsRequired(false);

            builder.Property(u => u.Address)
                .IsRequired();

            builder.Property(u => u.Town)
                .IsRequired();

            builder.Property(u => u.ZipCode)
                .IsRequired();

            builder.Property(u => u.Country)
                .IsRequired();

            builder.Property(u => u.PhoneFirst)
                .IsRequired(false);

            builder.Property(u => u.PhoneSecond)
                .IsRequired(false);

            builder.Property(u => u.MailFirst)
                .IsRequired(false);

            builder.Property(u => u.MailSecond)
                .IsRequired(false);

            builder.Property(u => u.Comment)
                .IsRequired(false);
        }
    }
}
