using GreenTree.Nachtragsmanagement.Core.Domain.Logging;
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.Logging
{
    public class LogMap : EntityTypeConfiguration<Log>
    {
        public LogMap()
        {
            ToTable("Log");

            HasKey(l => l.Id);

            Property(l => l.CreatedOnUtc);
            Property(l => l.FullMessage);
            Property(l => l.LogLevelId);
            Property(l => l.EntityId);
            Property(l => l.EntityType);
            Property(l => l.ShortMessage);
            Property(l => l.IpAddress);
            Property(l => l.PageUrl);
            Property(l => l.ReferrerUrl);

            Ignore(l => l.LogLevel);

            HasOptional(l => l.User)
                .WithMany()
                .HasForeignKey(l => l.UserId)
                .WillCascadeOnDelete(true);
        }
    }
}
