add change category

This commit is contained in:
KP9lKk 2024-12-17 09:38:50 +03:00
parent 9d5f71b2d5
commit 96db5c9188

View File

@ -11,6 +11,8 @@ stringBuilder.AppendLine();
stringBuilder.Append("2. Print rate"); stringBuilder.Append("2. Print rate");
stringBuilder.AppendLine(); stringBuilder.AppendLine();
stringBuilder.Append("3. Print items"); stringBuilder.Append("3. Print items");
stringBuilder.AppendLine();
stringBuilder.Append("4. Edit category");
Console.WriteLine(stringBuilder.ToString()); Console.WriteLine(stringBuilder.ToString());
if (!int.TryParse(Console.ReadLine(), out int menuPosition)) if (!int.TryParse(Console.ReadLine(), out int menuPosition))
{ {
@ -27,7 +29,19 @@ switch (menuPosition)
} }
break; break;
case 2: break; case 2: break;
case 3: ChangeCategory(); break;
default: default:
Console.WriteLine("Unkown Menu Position"); Console.WriteLine("Unkown Menu Position");
break; 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();
} }