using GreenTree.Strohrmann.ERP.Core.Domain.Business;
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 UnitMapping : IEntityTypeConfiguration<Unit>
    {
        public void Configure(EntityTypeBuilder<Unit> builder)
        {
            builder.ToTable("Units");

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

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

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

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

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

            builder.HasData(
                new Unit(8, "Milimeter", "mm", "Angabe in Einheit Milimeter"),
                new Unit(1, "Meter", "m", "Angabe in Einheit Meter"),
                new Unit(2, "Quadratmeter", "m²", "Angabe in Einheit Quadratmeter"),
                new Unit(3, "Kubikmeter", "m³", "Angabe in Einheit Kubikmeter"),
                new Unit(4, "Liter", "l", "Angabe in Einheit Liter"),
                new Unit(5, "Stück", "Stck.", "Angabe in Stückzahl"),
                new Unit(6, "Kilogramm", "Kg", "Angabe in Stückzahl"),
                new Unit(7, "Stunden", "Std.", "Angabe in Zeitstunden"));
        }
    }
}
