using BarDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;

namespace BarDatabaseImplement
{
    public class BarDatabase : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder OptionsBuilder)
        {
            if (OptionsBuilder.IsConfigured == false)
            {
                OptionsBuilder.UseNpgsql(@"Host=localhost;Database=Bar;Username=postgres;Password=postgres");
            }

            base.OnConfiguring(OptionsBuilder);

            AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
            AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
        }

        public virtual DbSet<Component> Components { set; get; }

        public virtual DbSet<Cocktail> Cocktails { set; get; }

        public virtual DbSet<CocktailComponent> CocktailComponents { set; get; }

        public virtual DbSet<Order> Orders { set; get; }

        public virtual DbSet<Client> Clients { set; get; }

        public virtual DbSet<Implementer> Implementers { set; get; }

        public virtual DbSet<MessageInfo> Messages { set; get; }
    }
}
