當前位置: 首頁>>代碼示例>>C#>>正文


C# Category.GetName方法代碼示例

本文整理匯總了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);
        }
開發者ID:Rick1970,項目名稱:todo-with-join-statement,代碼行數:16,代碼來源:CategoryTest.cs

示例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"];
            };
        }
開發者ID:jmk22,項目名稱:todo_categories_databasesextended,代碼行數:91,代碼來源:HomeModule.cs


注:本文中的ToDoList.Category.GetName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。