diff --git a/LootBoxSimulator/Program.cs b/LootBoxSimulator/Program.cs index 423b5fb..35d0689 100644 --- a/LootBoxSimulator/Program.cs +++ b/LootBoxSimulator/Program.cs @@ -1,29 +1,28 @@ using System.Reflection.Emit; using System.Runtime.InteropServices.ComTypes; +using System.Threading.Channels; using LootBoxSimulator.Models.DAO; RemoteDatabaseContext db = new RemoteDatabaseContext(); - - -//add value -CategoryDao newCategory = new CategoryDao +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) { - Name = "epic" -}; -db.Categories.Add(newCategory); -db.SaveChanges(); -//change value -var categoriesUpd = db.Categories.Find(3); -if(categoriesUpd == null) return; -categoriesUpd.Name = "rare"; -//remove value -var categories = db.Categories.Find(3); -if(categories == null) return; -db.Remove(categories); -db.SaveChanges(); + 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 -//display value -await foreach (var categoryDao in db.Categories) -{ - Console.WriteLine(categoryDao.Name); -} \ No newline at end of file + }; + db.Rates.Add(dao); +} +db.SaveChanges(); \ 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 16f358d..6c4e121 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+13f06cb083c5b4aeca07e78be088bd7df3d7e65d")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9c61ffba70b4d7b6c85c3d3d7b357920470df9fc")] [assembly: System.Reflection.AssemblyProductAttribute("LootBoxSimulator")] [assembly: System.Reflection.AssemblyTitleAttribute("LootBoxSimulator")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]