public static void Menu() { int offset = 2; int select; do { Console.WriteLine("╔═╤═╤═╡ BUILDING MENU ╞═════╗"); Console.WriteLine("║0├─┤Exit ║"); Console.WriteLine("║1├─┤Insert ║"); Console.WriteLine("╚═╧═╧═══════════════════════╝"); ShowAll(offset); Console.Write("> "); select = Formations.GetInt(Console.ReadLine()); Console.Clear(); if (select == 0) { return; } else if (select >= offset && select < General.Count + offset) { Update(General.Generals[select - offset].Id); } else if (select > 0) { string id = General.NextId; ManageGeneral.Update(new General { Id = id }); Update(id); } else { Formations.NotFound("Action"); } }while (true); }
private static void Update(string id) { string[] select; do { General general = General.GetGeneral(id); if (general == null) { return; } InputOutput[] inputsOutputs = general.GetInputOutputs; Power[] powers = general.GetPowers; ShowInfo(id); Console.WriteLine("╔═══╤╤╡ UPDATE BUILDING ╞═════╗"); Console.WriteLine("║ 0 ├┤ Exit ║"); Console.WriteLine("║ 1 ├┤ Edit general ║"); Console.WriteLine("╠═══╪╪════════════════════════╝"); //Power Console.WriteLine("║2 0├┤ Add Power"); for (int i = 0; i < powers.Length; i++) { Console.WriteLine("║2 {0}├┤ Edit {1}", i + 1, powers[i]); } //Input/Output Console.WriteLine("║5 0├┤ Add Input/Output"); for (int i = 0; i < inputsOutputs.Length; i++) { Console.WriteLine("║5 {0}├┤ Edit {1}", i + 1, inputsOutputs[i]); } Console.WriteLine("╠═══╪╪════════════════════════╗"); Console.WriteLine("║ 8 ├┤ Delete ║"); Console.WriteLine("╚═══╧╧════════════════════════╝"); Console.Write("> "); select = Console.ReadLine().Split(' '); Console.Clear(); if (select.First() == "0") { return; } else if (select.First() == "1") { ManageGeneral.Update(general); } else if (select.First() == "2") { if (select.Length == 2) { int subaction = Formations.GetInt(select[1]) - 1; if (subaction >= 0 && subaction < inputsOutputs.Length) { ManagePower.Update(powers[subaction]); } else if (subaction == -1) { ManagePower.Update(new Power { Id = Power.NextId, GeneralId = general.Id }); } else { Formations.NotFound("SubAction"); } } else { Formations.NotFound("SubAction"); } } else if (select.First() == "5") { if (select.Length == 2) { int subaction = Formations.GetInt(select[1]) - 1; if (subaction >= 0 && subaction < inputsOutputs.Length) { ManageInputOutput.Update(inputsOutputs[subaction]); } else if (subaction == -1) { ManageInputOutput.Update(new InputOutput(general.Id)); } else { Formations.NotFound("SubAction"); } } else { Formations.NotFound("SubAction"); } } else if (select.First() == "8") { Delete(id); } else { Formations.NotFound("Action"); } }while (true); }