LootBoxGenerator/LootBoxSimulator/Program.cs
2024-12-17 09:38:50 +03:00

47 lines
1.3 KiB
C#

using System.Reflection.Emit;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Channels;
using LootBoxSimulator.Models.DAO;
RemoteDatabaseContext db = new RemoteDatabaseContext();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("1. Print category");
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))
{
Console.WriteLine("Please enter a valid number");
return;
}
switch (menuPosition)
{
case 1:
foreach (var categoryDao in db.Categories)
{
Console.WriteLine($"Id: {categoryDao.Id} Name: {categoryDao.Name}");
}
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();
}