add action remove and add for category
This commit is contained in:
parent
96db5c9188
commit
ee5080f758
@ -40,8 +40,28 @@ void ChangeCategory()
|
||||
{
|
||||
if(!int.TryParse(Console.ReadLine(), out int CategoryID)) return;
|
||||
String CategoryName = Console.ReadLine();
|
||||
if(!String.IsNullOrEmpty(CategoryName)) return;
|
||||
if(String.IsNullOrEmpty(CategoryName)) return;
|
||||
var categoryDao = db.Categories.Find(CategoryID);
|
||||
categoryDao.Name = CategoryName;
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user