当前位置: 首页>>代码示例>>C#>>正文


C# Category.Save方法代码示例

本文整理汇总了C#中ToDoList.Category.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Category.Save方法的具体用法?C# Category.Save怎么用?C# Category.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ToDoList.Category的用法示例。


在下文中一共展示了Category.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_Delete_DeletesCategoryFromDatabase

        public void Test_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
              string name1 = "Home stuff";
              Category testCategory1 = new Category(name1);
              testCategory1.Save();

              string name2 = "Work stuff";
              Category testCategory2 = new Category(name2);
              testCategory2.Save();
              DateTime fakeTime = new DateTime(2016, 1, 1);

              Task testTask1 = new Task("Mow the lawn", testCategory1.GetId(),fakeTime);
              testTask1.Save();
              DateTime fakeTime1 = new DateTime(2016, 1, 1);

              Task testTask2 = new Task("Send emails", testCategory2.GetId(),fakeTime1);
              testTask2.Save();

              //Act
              testCategory1.Delete();
              List<Category> resultCategories = Category.GetAll();
              List<Category> testCategoryList = new List<Category> {testCategory2};

              List<Task> resultTasks = Task.GetAll();
              List<Task> testTaskList = new List<Task> {testTask2};

              //Assert
              Assert.Equal(testCategoryList, resultCategories);
              Assert.Equal(testTaskList, resultTasks);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:31,代码来源:CategoryTest.cs

示例2: Test_FindFindsCategoryInDatabase

    public void Test_FindFindsCategoryInDatabase()
    {
      //Arrange
      Category testCategory = new Category("Household chores");
      testCategory.Save();

      //Act
      Category foundCategory = Category.Find(testCategory.GetId());

      //Assert
      Assert.Equal(testCategory, foundCategory);
    }
开发者ID:jmk22,项目名称:todo_categories_databases_CRUD,代码行数:12,代码来源:CategoryTest.cs

示例3: T3_Save_SavesCategoryToDatabase

        public void T3_Save_SavesCategoryToDatabase()
        {
            // Arrange
              Category testCategory = new Category("Household chores");
              testCategory.Save();

              // Act
              List<Category> result = Category.GetAll();
              List<Category> testList = new List<Category>{testCategory};

              // Assert
              Assert.Equal(testList, result);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:13,代码来源:CategoryTest.cs

示例4: 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];
            };

            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"];
            };


            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"], Request.Form["category-id"]);
              newTask.Save();
              return View["success.cshtml"];
            };

            Post["/tasks/delete"] = _ => {
              Task.DeleteAll();
              return View["cleared.cshtml"];
            };

            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];
            };
        }
开发者ID:jtf86,项目名称:todo_rzor_databases_12m,代码行数:51,代码来源:HomeModule.cs

示例5: Test_SaveAssignsIdToCategoryObject

    public void Test_SaveAssignsIdToCategoryObject()
    {
      //Arrange
      Category testCategory = new Category("Household chores");
      testCategory.Save();

      //Act
      Category savedCategory = Category.GetAll()[0];

      int result = savedCategory.GetId();
      int testId = testCategory.GetId();

      //Assert
      Assert.Equal(testId, result);
    }
开发者ID:jmk22,项目名称:todo_categories_databases_CRUD,代码行数:15,代码来源:CategoryTest.cs

示例6: Test_AddCategory_AddsCategoryToTask

        public void Test_AddCategory_AddsCategoryToTask()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", new DateTime(2016, 2, 2), false);
              testTask.Save();

              Category testCategory = new Category("Home stuff");
              testCategory.Save();

              //Act
              testTask.AddCategory(testCategory);

              List<Category> result = testTask.GetCategories();
              List<Category> testList = new List<Category>{testCategory};

              //Assert
              Assert.Equal(testList, result);
        }
开发者ID:nlarion,项目名称:ToDoCsharp,代码行数:18,代码来源:TaskTest.cs

示例7: Test18_GetCategories_ReturnsAllTaskCategories

        public void Test18_GetCategories_ReturnsAllTaskCategories()
        {
            DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask = new Task("Mow the lawn",testTime);
              testTask.Save();

              Category testCategory1 = new Category("Home Stuff");
              testCategory1.Save();

              Category testCategory2 = new Category("Work Stuff");
              testCategory2.Save();

              testTask.AddCategory(testCategory1);
              List<Category> result = testTask.GetCategories();
              List<Category> testList= new List<Category>{testCategory1};

              Assert.Equal(testList,result);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:19,代码来源:TaskTest.cs

示例8: Test_Delete_DeletesCategoryAssociationsFromDatabase

        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", false);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
        }
开发者ID:Rouz1130,项目名称:todo_manyTomany,代码行数:20,代码来源:CategoryTest.cs

示例9: Test_Delete_DeletesTaskAssociationsFromDatabase

        public void Test_Delete_DeletesTaskAssociationsFromDatabase()
        {
            //Arrange
              Category testCategory = new Category("Home stuff");
              testCategory.Save();

              string testDescription = "Mow the lawn";
              Task testTask = new Task(testDescription, new DateTime(2016, 2, 2));
              testTask.Save();

              //Act
              testTask.AddCategory(testCategory);
              testTask.Delete();

              List<Task> resultCategoryTasks = testCategory.GetTasks();
              List<Task> testCategoryTasks = new List<Task> {};

              //Assert
              Assert.Equal(testCategoryTasks, resultCategoryTasks);
        }
开发者ID:nlarion,项目名称:ToDoCsharp,代码行数:20,代码来源:TaskTest.cs

示例10: Test_AddTask_AddsTaskToCategory

        public void Test_AddTask_AddsTaskToCategory()
        {
            //Arrange
              Category testCategory = new Category("Household chores");
              testCategory.Save();

              Task testTask = new Task("Mow the lawn", false);
              testTask.Save();

              Task testTask2 = new Task("Water the garden", false);
              testTask2.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.AddTask(testTask2);

              List<Task> result = testCategory.GetTasks();
              List<Task> testList = new List<Task>{testTask, testTask2};

              //Assert
              Assert.Equal(testList, result);
        }
开发者ID:Rouz1130,项目名称:todo_manyTomany,代码行数:22,代码来源:CategoryTest.cs

示例11: 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

示例12: HomeModule

        public HomeModule()
        {
            Get["/"] = _ => {
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Delete["/"]=_=>{
            Category.DeleteAll();
            Task.DeleteAll();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/category/add"] = _ => View["add_category.cshtml"];

              Post["/category/add"] = _ => {
            Category newCategory = new Category(Request.Form["name"]);
            newCategory.Save();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/task/add"] = _ => {
            List<Category> categoryList = Category.GetAll();
            return View["add_task.cshtml", categoryList];
              };

              Post["/task/add"] = _ => {
            Task newTask = new Task(Request.Form["description"], Request.Form["date"]);
            newTask.Save();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/task/all"] = _ => {
            List<Task> allTasks = Task.GetAll();
            return View["task_list.cshtml", allTasks];
              };

              Get["/category/{id}"] = parameters => {
            Category currentCategory = Category.Find(parameters.id);
            Console.WriteLine(currentCategory.GetName());
            List<Task> tasksInCategory = currentCategory.GetTasks();
            Console.WriteLine(tasksInCategory.Count);
            return View["task_list.cshtml", tasksInCategory];
              };

              Get["task/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Task SelectedTask = Task.Find(parameters.id);
            List<Category> TaskCategories = SelectedTask.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task", SelectedTask);
            model.Add("taskCategories", TaskCategories);
            model.Add("allCategories", AllCategories);
            return View["task.cshtml", model];
              };

              Get["category/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category SelectedCategory = Category.Find(parameters.id);
            List<Task> CategoryTasks = SelectedCategory.GetTasks();
            List<Task> AllTasks = Task.GetAll();
            model.Add("category", SelectedCategory);
            model.Add("categoryTasks", CategoryTasks);
            model.Add("allTasks", AllTasks);
            return View["category.cshtml", model];
              };

              Post["task/add_category"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            task.AddCategory(category);
            Dictionary<string, object> model = new Dictionary<string, object>();
            model.Add("task", task);
            model.Add("taskCategories", task.GetCategories());
            model.Add("allCategories", Category.GetAll());
            return View["task.cshtml", model];
              };

              Post["category/add_task"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            category.AddTask(task);
            Dictionary<string, object> model = new Dictionary<string, object>();
            model.Add("category", category);
            model.Add("categoryTasks", category.GetTasks());
            model.Add("allTasks", Task.GetAll());
            return View["category.cshtml", model];
              };

              Delete["category/{id}/delete"] = parameters =>
              {
            Category category = Category.Find(parameters.id);
            category.Delete();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

//.........这里部分代码省略.........
开发者ID:CharlesEwel,项目名称:csharp-todo-week4,代码行数:101,代码来源:HomeModule.cs

示例13: Test_GetTasks_ReturnAllCategoryTasks

        public void Test_GetTasks_ReturnAllCategoryTasks()
        {
            Category testCategory = new Category("Househould chores");
              testCategory.Save();
              DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask1= new Task("Mow the lawn",testTime);
              testTask1.Save();

              Task testTask2 = new Task("Buy plane ticket",testTime);
              testTask2.Save();

              testCategory.AddTask(testTask1);
              List<Task> savedTasks = testCategory.GetTasks();
              List<Task> testList= new List<Task>{testTask1};
              Assert.Equal(testList,savedTasks);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:17,代码来源:CategoryTest.cs

示例14: Test_Delete_DeletesCategoryAssociationsFromDatabase

        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask = new Task("Mow the lawn",testTime);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};
              List<Task> resultsTasks= Task.GetAll();
              List<Task> testTasks= new List<Task>{testTask};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
              Assert.Equal(testTasks, resultsTasks);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:25,代码来源:CategoryTest.cs

示例15: T8_Delete_DeletesCategoryFromDatabase

        public void T8_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
              string name1 = "Home stuff";
              Category testCategory1 = new Category(name1);
              testCategory1.Save();

              string name2 = "Work stuff";
              Category testCategory2 = new Category(name2);
              testCategory2.Save();

              //Act
              testCategory1.Delete();
              List<Category> resultCategories = Category.GetAll();
              List<Category> testCategoryList = new List<Category> {testCategory2};

              //Assert
              Assert.Equal(testCategoryList, resultCategories);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:19,代码来源:CategoryTest.cs


注:本文中的ToDoList.Category.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。