From ee5080f7585365af1777c94f6d90ae68f354fd39 Mon Sep 17 00:00:00 2001 From: KP9lKk Date: Tue, 17 Dec 2024 15:43:34 +0300 Subject: [PATCH] add action remove and add for category --- LootBoxSimulator/Program.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/LootBoxSimulator/Program.cs b/LootBoxSimulator/Program.cs index 5bb2026..62eb0e4 100644 --- a/LootBoxSimulator/Program.cs +++ b/LootBoxSimulator/Program.cs @@ -40,8 +40,28 @@ void ChangeCategory() { if(!int.TryParse(Console.ReadLine(), out int CategoryID)) return; String CategoryName = Console.ReadLine(); - if(!String.IsNullOrEmpty(CategoryName)) return; + if(String.IsNullOrEmpty(CategoryName)) return; var categoryDao = db.Categories.Find(CategoryID); categoryDao.Name = CategoryName; db.SaveChanges(); +} + +void RemoveCategory() +{ + Console.WriteLine("Please enter a Category ID to remove"); + if(!int.TryParse(Console.ReadLine(), out int CategoryID)) return; + var categoryDao = db.Categories.Find(CategoryID); + db.Categories.Remove(categoryDao); + db.SaveChanges(); +} + +void AddCategory() +{ + Console.WriteLine("Please enter a Category Name for new category"); + String CategoryName = Console.ReadLine(); + if(String.IsNullOrEmpty(CategoryName)) return; + CategoryDao categoryDao = new CategoryDao(); + categoryDao.Name = CategoryName; + db.Categories.Add(categoryDao); + db.SaveChanges(); } \ No newline at end of file