add change category
This commit is contained in:
parent
9d5f71b2d5
commit
96db5c9188
@ -11,6 +11,8 @@ 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))
|
||||
{
|
||||
@ -27,7 +29,19 @@ switch (menuPosition)
|
||||
}
|
||||
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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user