LootBoxGenerator/LootBoxSimulator/Program.cs

28 lines
812 B
C#
Raw Normal View History

2024-12-16 06:29:02 +00:00
using System.Reflection.Emit;
using System.Runtime.InteropServices.ComTypes;
2024-12-16 11:24:55 +00:00
using System.Threading.Channels;
2024-12-16 06:29:02 +00:00
using LootBoxSimulator.Models.DAO;
2024-12-05 11:29:52 +00:00
RemoteDatabaseContext db = new RemoteDatabaseContext();
2024-12-16 11:24:55 +00:00
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)
2024-12-16 06:29:02 +00:00
{
2024-12-16 11:24:55 +00:00
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
2024-12-16 06:29:02 +00:00
2024-12-16 11:24:55 +00:00
};
db.Rates.Add(dao);
}
db.SaveChanges();