LootBoxGenerator/LootBoxSimulator/Program.cs

67 lines
1.9 KiB
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 13:07:23 +00:00
using System.Text;
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 13:07:23 +00:00
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("1. Print category");
stringBuilder.AppendLine();
stringBuilder.Append("2. Print rate");
stringBuilder.AppendLine();
stringBuilder.Append("3. Print items");
2024-12-17 06:38:50 +00:00
stringBuilder.AppendLine();
stringBuilder.Append("4. Edit category");
2024-12-16 13:07:23 +00:00
Console.WriteLine(stringBuilder.ToString());
if (!int.TryParse(Console.ReadLine(), out int menuPosition))
2024-12-16 06:29:02 +00:00
{
2024-12-16 13:07:23 +00:00
Console.WriteLine("Please enter a valid number");
return;
2024-12-16 11:24:55 +00:00
}
2024-12-16 13:07:23 +00:00
switch (menuPosition)
{
case 1:
foreach (var categoryDao in db.Categories)
{
Console.WriteLine($"Id: {categoryDao.Id} Name: {categoryDao.Name}");
}
break;
case 2: break;
2024-12-17 06:38:50 +00:00
case 3: ChangeCategory(); break;
2024-12-16 13:07:23 +00:00
default:
Console.WriteLine("Unkown Menu Position");
break;
2024-12-17 06:38:50 +00:00
}
void ChangeCategory()
{
if(!int.TryParse(Console.ReadLine(), out int CategoryID)) return;
String CategoryName = Console.ReadLine();
2024-12-17 12:43:34 +00:00
if(String.IsNullOrEmpty(CategoryName)) return;
2024-12-17 06:38:50 +00:00
var categoryDao = db.Categories.Find(CategoryID);
categoryDao.Name = CategoryName;
db.SaveChanges();
2024-12-17 12:43:34 +00:00
}
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();
2024-12-16 13:07:23 +00:00
}