예제 #1
0
        private static void StartProgram()
        {
            var input = "";

            while (true)
            {
                area = Controller.Area.Menu;
                Console.WriteLine("===========================================================================");
                Console.WriteLine("Willkommen beim Verwaltungsprogramm 'Bücherwurm'!");
                Console.WriteLine("===========================================================================");
                Console.WriteLine();
                Console.WriteLine("Schreiben Sie die Nummer der Kategorie oder 'b' um das Programm zu beenden!");
                Output(new List <string> {
                    "1. Bücher", "2. Magazine", "3. Exemplare", "4. Leihvorgang", "5. Gelöschte Leihvorgänge", ""
                });
                input = Input(0, 5, "b");
                if (input == "b")
                {
                    break;
                }
                Console.Clear();
                ChooseCategory(input);
            }
            //Speichere die Daten
            JSONIO.SaveDataController();
            JSONIO.SaveData("products.json", Controller.products);
            JSONIO.SaveData("copies.json", Controller.copies);
            JSONIO.SaveData("ebooks.json", Controller.eProducts);
            JSONIO.SaveData("rents.json", Controller.rents);
            JSONIO.SaveData("delrents.json", Controller.delRents);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var jsonString = File.ReadAllText("books.json");

            if (!File.Exists("copies.json"))
            {
                Controller.lastProductId = 0;
                Controller.lastCopyId    = 0;
                Controller.lastDelRentId = 0;
                Controller.lastRentId    = 0;
                Controller.lastEId       = 0;
                JSONIO.ReadData("books.json");
                JSONIO.ReadData("Magazine.json");
            }
            else
            {
                JSONIO.ReadDataController();
                JSONIO.ReadDataCopies();
                JSONIO.ReadDataEBooks();
                JSONIO.ReadDataRents();
                JSONIO.ReadDataDelRents();
            }

            StartProgram();
        }
예제 #3
0
        bool SaveModel(string filename)
        {
            if (JSONIO.ExportPatient(filename, modelDefinition) && modelDefinition != null)
            {
                modelInterface.StatusMessage = $"Exported patient {filename}. {Environment.NewLine}";

                return(true);
            }
            else
            {
                modelInterface.StatusMessage = $"Failed to export patient to {filename}. {Environment.NewLine}";

                return(false);
            }
        }
예제 #4
0
        bool LoadModelFromJSON(string json_file)
        {
            modelDefinition = JSONIO.ImportPatientFromText(json_file);

            if (modelDefinition != null)
            {
                modelInterface.StatusMessage = $"Imported patient : {modelDefinition.name}.";
                // initialize the loaded model
                InitModel();

                ModelLoaded = true;
            }
            else
            {
                modelInterface.StatusMessage = $"Failed to import patient.";

                ModelLoaded = false;
            }

            return(ModelLoaded);
        }
예제 #5
0
        bool LoadModelFromDisk(string filename)
        {
            modelDefinition = JSONIO.ImportPatientFromFileOnDisk(filename);

            if (modelDefinition != null)
            {
                modelInterface.StatusMessage = $"Imported patient {filename}. {Environment.NewLine}";
                // initialize the loaded model
                InitModel();

                ModelLoaded = true;
            }
            else
            {
                modelInterface.StatusMessage = $"Failed to import patient {filename}. {Environment.NewLine}";

                ModelLoaded = true;
            }

            return(ModelLoaded);
        }
예제 #6
0
 private void AddToConfig(AgentConfig agentConfig)
 {
     FileIO.Write(_configLocation, JSONIO.ToJSON <ReadOnlyCollection <AgentConfig> >(base.AsReadOnly()));
 }