当前位置: 首页>>代码示例>>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;未经允许,请勿转载。