using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MS.Entities.AccountingService_Models;
using MS.Entities.Core;
using MS.Entities.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.DbContexts.AccountingService
{
    public class MembershipGroupMap : IEntityTypeConfiguration<MembershipGroup>
    {
        public void Configure(EntityTypeBuilder<MembershipGroup> entity)
        {
            entity.ToTable("membership_group");

            entity.Property(e => e.Id)
                .HasColumnName("id")
                .ValueGeneratedNever();

            entity.Property(e => e.BuInfoCreatedId).HasColumnName("bu_info_created_id");

            entity.Property(e => e.BuInfoId).HasColumnName("bu_info_id");

            entity.Property(e => e.ConfigAppliedItems)
                .HasColumnName("config_applied_items")
            .HasMaxLength(255);

            entity.Property(e => e.ConfigCreationTimeFrom).HasColumnName("config_creation_time_from");

            entity.Property(e => e.ConfigCreationTimeTo).HasColumnName("config_creation_time_to");

            entity.Property(e => e.ConfigEAccountBalanceFrom)
                .HasColumnName("config_e_account_balance_from")
                .HasDefaultValueSql("0");

            entity.Property(e => e.ConfigEAccountBalanceTo)
                .HasColumnName("config_e_account_balance_to")
                .HasDefaultValueSql("0");

            entity.Property(e => e.ConfigEndTimeOfDay)
                .HasColumnName("config_end_time_of_day")
                .HasMaxLength(255);

            entity.Property(e => e.ConfigGender).HasColumnName("config_gender");

            entity.Property(e => e.ConfigLevel)
                .HasColumnName("config_level")
                .HasMaxLength(255);

            entity.Property(e => e.ConfigPhysicalCard).HasColumnName("config_physical_card");

            entity.Property(e => e.ConfigRfmFrequencyFrom).HasColumnName("config_rfm_frequency_from");

            entity.Property(e => e.ConfigRfmFrequencyTo).HasColumnName("config_rfm_frequency_to");

            entity.Property(e => e.ConfigRfmMonetaryAbove).HasColumnName("config_rfm_monetary_above");

            entity.Property(e => e.ConfigRfmMonetaryBelow).HasColumnName("config_rfm_monetary_below");

            entity.Property(e => e.ConfigRfmRecencyBefore).HasColumnName("config_rfm_recency_before");

            entity.Property(e => e.ConfigSpecifiedDateOfMonth)
                .HasColumnName("config_specified_date_of_month")
                .HasMaxLength(255);

            entity.Property(e => e.ConfigSpecifiedDateOfMonthCount).HasColumnName("config_specified_date_of_month_count");

            entity.Property(e => e.ConfigSpecifiedDayOfWeek)
                .HasColumnName("config_specified_day_of_week")
                .HasMaxLength(255);

            entity.Property(e => e.ConfigSpecifiedDayOfWeekCount).HasColumnName("config_specified_day_of_week_count");

            entity.Property(e => e.ConfigStartTimeOfDay)
                .HasColumnName("config_start_time_of_day")
                .HasMaxLength(255);

            entity.Property(e => e.ConfigTimeOfDayCount).HasColumnName("config_time_of_day_count");

            entity.Property(e => e.CreationTime).HasColumnName("creation_time");

            entity.Property(e => e.Description)
                .HasColumnName("description")
                .HasMaxLength(255);

            entity.Property(e => e.GroupId)
                .HasColumnName("group_id")
                .HasMaxLength(255);

            entity.Property(e => e.GroupMemberLimit).HasColumnName("group_member_limit");

            entity.Property(e => e.GroupName)
                .HasColumnName("group_name")
                .HasMaxLength(255);

            entity.Property(e => e.GroupStatus)
                .HasColumnName("group_status")
                .HasDefaultValueSql("1");

            entity.Property(e => e.GroupType).HasColumnName("group_type");

            entity.Property(e => e.LastModified)
                .HasColumnName("last_modified")
                .HasDefaultValueSql("now()");

            entity.Property(e => e.LastRefreshTime).HasColumnName("last_refresh_time");

            entity.Property(e => e.MembershipLevel).HasColumnName("membership_level");

            //entity.HasOne(d => d.BuInfoCreated)
            //    .WithMany(p => p.MembershipGroupBuInfoCreated)
            //    .HasForeignKey(d => d.BuInfoCreatedId)
            //    .HasConstraintName("membership_group_bu_info_created_id_fkey");

            //entity.HasOne(d => d.BuInfo)
            //    .WithMany(p => p.MembershipGroupBuInfo)
            //    .HasForeignKey(d => d.BuInfoId)
            //    .HasConstraintName("membership_group_bu_info_id_fkey");

            entity.HasOne(d => d.MembershipLevelNavigation)
                .WithMany(p => p.MembershipGroup)
                .HasForeignKey(d => d.MembershipLevel)
                .HasConstraintName("membership_group_membership_level_fkey");
        }
    }
}
