本文整理汇总了C#中ToDoList.Category.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# Category.GetName方法的具体用法?C# Category.GetName怎么用?C# Category.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToDoList.Category
的用法示例。
在下文中一共展示了Category.GetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: T7_Update_UpdatesCategoryInDatabase
public void T7_Update_UpdatesCategoryInDatabase()
{
//Arrange
string name = "Home Chores";
Category testCategory = new Category(name);
testCategory.Save();
string newName = "Work Chores";
//Act
testCategory.Update(newName);
string result = testCategory.GetName();
//Assert
Assert.Equal(newName, result);
}
示例2: HomeModule
public HomeModule()
{
//Index
Get["/"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["index.cshtml", AllCategories];
};
//Get: Lists
Get["/tasks"] = _ => {
List<Task> AllTasks = Task.GetAll();
return View["tasks.cshtml", AllTasks];
};
Get["/categories"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["categories.cshtml", AllCategories];
};
//Create new category
Get["/categories/new"] = _ => {
return View["categories_form.cshtml"];
};
Post["/categories/new"] = _ => {
Category newCategory = new Category(Request.Form["category-name"]);
newCategory.Save();
return View["success.cshtml"];
};
//Create new task
Get["/tasks/new"] = _ => {
List<Category> AllCategories = Category.GetAll();
return View["tasks_form.cshtml", AllCategories];
};
Post["/tasks/new"] = _ => {
Task newTask = new Task(Request.Form["task-description"]);
newTask.Save();
Category taskCategory = new Category(Request.Form["category-id"]);
Console.WriteLine("taskCategory: {0}", taskCategory.GetName());
taskCategory.AddTask(newTask);
return View["success.cshtml"];
};
//"Clear All" routes
Post["/tasks/clear"] = _ => {
Task.DeleteAll();
return View["cleared.cshtml"];
};
Post["/categories/clear"] = _ => {
Category.DeleteAll();
return View["cleared.cshtml"];
};
//View specific category
Get["categories/{id}"] = parameters => {
Dictionary<string, object> model = new Dictionary<string, object>();
var SelectedCategory = Category.Find(parameters.id);
var CategoryTasks = SelectedCategory.GetTasks();
model.Add("category", SelectedCategory);
model.Add("tasks", CategoryTasks);
return View["category.cshtml", model];
};
//View specific task
Get["tasks/{id}"] = parameters => {
Dictionary<string, object> model = new Dictionary<string, object>();
Task SelectedTask = Task.Find(parameters.id);
return View["task.cshtml", SelectedTask];
};
//Edit specific category
Get["category/edit/{id}"] = parameters => {
Category SelectedCategory = Category.Find(parameters.id);
return View["category_edit.cshtml", SelectedCategory];
};
Post["category/edit/{id}"] = parameters => {
Category SelectedCategory = Category.Find(parameters.id);
SelectedCategory.Update(Request.Form["category-name"]);
return View["success.cshtml"];
};
//Delete specific category
Get["category/delete/{id}"] = parameters => {
Category SelectedCategory = Category.Find(parameters.id);
return View["category_delete.cshtml", SelectedCategory];
};
Post["category/delete/{id}"] = parameters => {
Category SelectedCategory = Category.Find(parameters.id);
SelectedCategory.Delete();
return View["success.cshtml"];
};
}