using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Data.Mapping.User
{
    public class UserMap : EntityTypeConfiguration<Core.Domain.User.User>
    {
        public UserMap()
        {
            ToTable("User");

            HasKey(u => u.Id);

            Property(u => u.CustomNumber);
            Property(u => u.Forename);
            Property(u => u.Lastname);
            Property(u => u.MailAddress);
            Property(u => u.Password);
            Property(u => u.IsChanged);

            Ignore(u => u.CurrentRole);

            HasMany(c => c.Roles)
                .WithMany()
                .Map(m => m.ToTable("UserRoles"));

            HasMany(c => c.MailNotifications)
                .WithMany()
                .Map(m => m.ToTable("UserMailNotifications"));
        }
    }
}
