From 9c1a47e720b152aec6e6d2d7cd0d3df1b095e7a0 Mon Sep 17 00:00:00 2001 From: KP9lKk Date: Mon, 16 Dec 2024 16:07:23 +0300 Subject: [PATCH] add menu --- LootBoxSimulator/Program.cs | 45 ++++++++++--------- .../net8.0/LootBoxSimulator.AssemblyInfo.cs | 2 +- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/LootBoxSimulator/Program.cs b/LootBoxSimulator/Program.cs index 35d0689..897812c 100644 --- a/LootBoxSimulator/Program.cs +++ b/LootBoxSimulator/Program.cs @@ -1,28 +1,33 @@ using System.Reflection.Emit; using System.Runtime.InteropServices.ComTypes; +using System.Text; using System.Threading.Channels; using LootBoxSimulator.Models.DAO; RemoteDatabaseContext db = new RemoteDatabaseContext(); -Console.WriteLine("Enter path to file"); -string? path = Console.ReadLine(); -if (path == null) return; -if (!bool.TryParse(Console.ReadLine(), out bool HaveHeader)) return; -StreamReader file = new StreamReader(path); -string row = String.Empty; -if(HaveHeader) row = file.ReadLine(); -Console.WriteLine(row); -while ((row = file.ReadLine()) != null) +StringBuilder stringBuilder = new StringBuilder(); +stringBuilder.Append("1. Print category"); +stringBuilder.AppendLine(); +stringBuilder.Append("2. Print rate"); +stringBuilder.AppendLine(); +stringBuilder.Append("3. Print items"); +Console.WriteLine(stringBuilder.ToString()); +if (!int.TryParse(Console.ReadLine(), out int menuPosition)) { - var line = row.Split(','); - if(!decimal.TryParse(line[2], out var decimalValue)) continue; - RateDao dao = new RateDao - { - Name = line[0], - Color = line[1], - Rate = decimalValue - - }; - db.Rates.Add(dao); + Console.WriteLine("Please enter a valid number"); + return; } -db.SaveChanges(); \ No newline at end of file + +switch (menuPosition) +{ + case 1: + foreach (var categoryDao in db.Categories) + { + Console.WriteLine($"Id: {categoryDao.Id} Name: {categoryDao.Name}"); + } + break; + case 2: break; + default: + Console.WriteLine("Unkown Menu Position"); + break; +} \ No newline at end of file diff --git a/LootBoxSimulator/obj/Debug/net8.0/LootBoxSimulator.AssemblyInfo.cs b/LootBoxSimulator/obj/Debug/net8.0/LootBoxSimulator.AssemblyInfo.cs index 6c4e121..aed43b5 100644 --- a/LootBoxSimulator/obj/Debug/net8.0/LootBoxSimulator.AssemblyInfo.cs +++ b/LootBoxSimulator/obj/Debug/net8.0/LootBoxSimulator.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("LootBoxSimulator")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c61ffba70b4d7b6c85c3d3d7b357920470df9fc")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1889ede86630630ebb95b23f978ced8ff8c96694")] [assembly: System.Reflection.AssemblyProductAttribute("LootBoxSimulator")] [assembly: System.Reflection.AssemblyTitleAttribute("LootBoxSimulator")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]