using CouchDB.Driver;
using CouchDB.Driver.Options;
using CouchDB.Driver.Types;
using DAL.PGModels;
using MongoDB.Bson;
using MongoDB.Driver;

namespace ConsoleAppDB
{
    internal class Program
    {
        static void Main(string[] args)
        {


            var connectionString = "mongodb://localhost:27017/";
            if (connectionString == null)
            {
                Console.WriteLine("You must set your 'MONGODB_URI' environment variable. To learn how to set it, see https://www.mongodb.com/docs/drivers/csharp/current/get-started/create-connection-string");
                Environment.Exit(0);
            }
            var client = new MongoClient(connectionString);
            var collection = client.GetDatabase("myfirst").GetCollection<MMM>("A");
            List<MMM> list1 = new List<MMM>();
            for (int i = 0; i < 10000; i++)
            {
                MMM r = new MMM();
                list1.Add(r);
            }
            collection.InsertMany(list1);

            //var filter = Builders<BsonDocument>.Filter.Eq("title", "Back to the Future");
            //var document = collection.Find(filter).First();
            //Console.WriteLine(document);

            using PostgresContext t = new PostgresContext();
            for (int i = 0; i < i; i++)
            {
                TclTvMonitorlog t1 = new TclTvMonitorlog();
                t1.HotelCode = "1001";
                t.TclTvMonitorlogs.Add(t1);
            }

            // Usage
            var context = new MyDeathStarContext();

            for (int j = 0; j < 100; j++)
            {

                List<Rebel> list = new List<Rebel>();
                for (int i = 0; i < 1000; i++)
                {
                    Rebel r = new Rebel();
                    list.Add(r);
                }
                context.Rebels.AddOrUpdateRangeAsync(list).Wait();
            }

            Console.WriteLine("Hello, World!");
            Console.ReadKey();
        }
    }
    public class MMM
    {
         public ObjectId _id { get; set; }
        public string name { get; set; }
    }
    public class Rebel : CouchDocument
    {
         public ObjectId _id { get; set; }
        public string name { get; set; }
    }
    public class MyDeathStarContext : CouchContext
    {
        public CouchDatabase<Rebel> Rebels { get; set; }

        protected override void OnConfiguring(CouchOptionsBuilder optionsBuilder)
        {
            optionsBuilder
              .UseEndpoint("http://localhost:5984/")
              .EnsureDatabaseExists()
              .UseBasicAuthentication(username: "admin", password: "123456");
        }
    }
}
