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 RoleMap : EntityTypeConfiguration<Core.Domain.User.Role>
    {
        public RoleMap()
        {
            ToTable("Role");

            HasKey(r => r.Id);

            Property(r => r.Description);
            Property(r => r.Level);
            Property(r => r.SeeOnlyAssigned);

            HasMany(r => r.Functions)
                .WithMany()
                .Map(m => m.ToTable("RoleFunctions"));

            HasMany(m => m.Users)
                .WithMany(u => u.Roles)
                .Map(m => m.ToTable("UserRoles"));
        }
    }
}
