From 96db5c9188c8a7cbb5570c37faf1c90d68b1a399 Mon Sep 17 00:00:00 2001 From: KP9lKk Date: Tue, 17 Dec 2024 09:38:50 +0300 Subject: [PATCH] add change category --- LootBoxSimulator/Program.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/LootBoxSimulator/Program.cs b/LootBoxSimulator/Program.cs index 897812c..5bb2026 100644 --- a/LootBoxSimulator/Program.cs +++ b/LootBoxSimulator/Program.cs @@ -11,6 +11,8 @@ stringBuilder.AppendLine(); stringBuilder.Append("2. Print rate"); stringBuilder.AppendLine(); stringBuilder.Append("3. Print items"); +stringBuilder.AppendLine(); +stringBuilder.Append("4. Edit category"); Console.WriteLine(stringBuilder.ToString()); if (!int.TryParse(Console.ReadLine(), out int menuPosition)) { @@ -27,7 +29,19 @@ switch (menuPosition) } break; case 2: break; + + case 3: ChangeCategory(); break; default: Console.WriteLine("Unkown Menu Position"); break; +} + +void ChangeCategory() +{ + if(!int.TryParse(Console.ReadLine(), out int CategoryID)) return; + String CategoryName = Console.ReadLine(); + if(!String.IsNullOrEmpty(CategoryName)) return; + var categoryDao = db.Categories.Find(CategoryID); + categoryDao.Name = CategoryName; + db.SaveChanges(); } \ No newline at end of file