using System;
using System.Collections.Generic;

namespace SendungsportalClient
{
    class Program
    {
        static void Main(string[] args)
        {
            // ---- Konfiguration ----
            string basisUrl = "http://localhost:8000";   // Referenz-Backend
            string apiKey   = "nordfracht-2026";
            string csvPfad  = "auftraege.csv";

            // ---- Modul 1: Import ----
            CsvImporter importer = new CsvImporter();
            List<Auftrag> roh = importer.Importiere(csvPfad);
            Console.WriteLine("Importiert: " + roh.Count + " Datensaetze");

            // ---- Modul 2: Validierung ----
            List<string> protokoll = new List<string>();
            Validierung pruefer = new Validierung();
            List<Auftrag> gueltige = pruefer.Pruefe(roh, protokoll);
            Console.WriteLine("Gueltig: " + gueltige.Count + " / Fehler: " + protokoll.Count);

            // ---- Modul 3: an das Backend senden ----
            RestClient client = new RestClient(basisUrl, apiKey);
            foreach (Auftrag a in gueltige)
            {
                bool ok = client.Sende(a);
                Console.WriteLine((ok ? "OK     " : "FEHLER ") + a.Kunde);
            }

            // ---- Anzeige: alle Auftraege abrufen ----
            List<Auftrag> alle = client.HoleAlle();
            Console.WriteLine("Im Backend stehen jetzt " + alle.Count + " Auftraege.");

            Console.WriteLine("Fertig. Taste druecken ...");
            Console.ReadKey();
        }
    }
}
