using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using GreenTree.Maschinenbestellungen.Core.Domain.Rights;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace GreenTree.Maschinenbestellungen.Domain.Model.Rights
{
    public class UserMapping : IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            builder.ToTable("Users");

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

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

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

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

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

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

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

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

            builder.Property(u => u.Activated)
                .IsRequired()
                .HasDefaultValue(true);
        }
    }
}
