using System;
using System.Threading.Tasks;
using BLL.Services;
using DAL.Repositories;
using DB;
using Microsoft.Extensions.Logging;
using MDL.Models;

class Program
{
    static async Task Main(string[] args)
    {
        // Create dependencies
        var loggerFactory = LoggerFactory.Create(builder =>
        {
            builder.AddConsole();
        });
        var logger = loggerFactory.CreateLogger<ShippingHandoverFormService>();
        
        var dbProvider = new DbProvider();
        var repository = new ShippingHandoverFormRepository(dbProvider);
        var service = new ShippingHandoverFormService(repository, logger);
        
        // Test the insert method
        Console.WriteLine("Testing shipping handover form insertion...");
        
        // Test 1: Insert first form
        var form1 = new ShippingHandoverFormEntity
        {
            HandoverNumber = "TEST-" + DateTime.Now.Ticks,
            Channel = "GOFO",
            Creator = "test_user",
            TimeZone = "America/New_York"
        };
        
        var id1 = await service.CreateShippingHandoverFormAsync(form1);
        Console.WriteLine($"Inserted form 1 with ID: {id1}");
        
        // Test 2: Insert second form
        var form2 = new ShippingHandoverFormEntity
        {
            HandoverNumber = "TEST-" + (DateTime.Now.Ticks + 1),
            Channel = "USPS",
            Creator = "test_user",
            TimeZone = "America/New_York"
        };
        
        var id2 = await service.CreateShippingHandoverFormAsync(form2);
        Console.WriteLine($"Inserted form 2 with ID: {id2}");
        
        // Test 3: Insert third form
        var form3 = new ShippingHandoverFormEntity
        {
            HandoverNumber = "TEST-" + (DateTime.Now.Ticks + 2),
            Channel = "UPS",
            Creator = "test_user",
            TimeZone = "America/New_York"
        };
        
        var id3 = await service.CreateShippingHandoverFormAsync(form3);
        Console.WriteLine($"Inserted form 3 with ID: {id3}");
        
        Console.WriteLine("Test completed!");
        Console.WriteLine($"Returned IDs: {id1}, {id2}, {id3}");
        Console.WriteLine($"IDs should be incrementing and not all 1");
    }
}