using System;
using Hncore.Infrastructure.EF;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Hncore.Pass.PaymentCenter.Domain
{
    public partial class PaymentContext : DbContextBase
    {
        public PaymentContext(DbContextOptions<PaymentContext> options, IHttpContextAccessor httpContextAccessor) :
            base(options, httpContextAccessor)
        {
        }

        public virtual DbSet<PaymentRecord> PaymentRecord { get; set; }
        public virtual DbSet<Manager> Manager { get; set; }
        public virtual DbSet<PaymentNotify> PaymentRecordNotify { get; set; }
        public virtual DbSet<RefundRecord> PaymentRefundRecord { get; set; }
        public virtual DbSet<TenantEntity> Tenant { get; set; }
        public virtual DbSet<TenantStore> TenantStore { get; set; }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Manager>(entity =>
            {
                entity.ToTable("manager");
                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });
          
            modelBuilder.Entity<PaymentNotify>(entity =>
            {
                entity.ToTable("payment_record_notify");
                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });

            modelBuilder.Entity<RefundRecord>(entity =>
            {
                entity.ToTable("payment_refund_record");
                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });

            modelBuilder.Entity<TenantEntity>(entity =>
            {
                entity.ToTable("tenant");
                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });

            modelBuilder.Entity<TenantStore>(entity =>
            {
                entity.ToTable("tenant_store");

                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });
            modelBuilder.Entity<PaymentRecord>(entity =>
            {
                entity.ToTable("payment_record");

                entity.HasKey(p => p.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
            });
        }
    }
}
