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


C# Task.GetId方法代码示例

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


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

示例1: Test_FindFindsTaskInDatabase

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

      //Act
      Task foundTask = Task.Find(testTask.GetId());

      //Assert
      Assert.Equal(testTask, foundTask);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:12,代码来源:TaskTest.cs

示例2: Test_Find_FindsTaskInDatabase

        public void Test_Find_FindsTaskInDatabase()
        {
            //Arrange
              DateTime fakeTime = new DateTime(2016, 1, 1);
              Task testTask = new Task("Mow the lawn", 1, fakeTime);
              testTask.Save();

              //Act
              Task foundTask = Task.Find(testTask.GetId());

              //Assert
              Assert.Equal(testTask, foundTask);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:13,代码来源:TaskTest.cs

示例3: Test_SaveAssignsIdToObject

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

      //Act
      Task savedTask = Task.GetAll()[0];

      int result = savedTask.GetId();
      int testId = testTask.GetId();

      //Assert
      Assert.Equal(testId, result);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:15,代码来源:TaskTest.cs

示例4: Test_Save_AssignsIdToObject

        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
              DateTime fakeTime = new DateTime(2016, 1, 1);
              Task testTask = new Task("Mow the lawn", 1, fakeTime);

              //Act
              testTask.Save();
              Task savedTask = Task.GetAll()[0];

              int result = savedTask.GetId();
              int testId = testTask.GetId();

              //Assert
              Assert.Equal(testId, result);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:16,代码来源:TaskTest.cs

示例5: AddTask

        public void AddTask(Task newTask)
        {
            SqlConnection conn = DB.Connection();
              conn.Open();

              SqlCommand cmd = new SqlCommand("INSERT INTO categories_tasks(category_id,task_id) VALUES(@CategoryId,@TaskId);",conn);
              SqlParameter categoryIdParameter = new SqlParameter();
              categoryIdParameter.ParameterName = "@categoryId";
              categoryIdParameter.Value=this.GetId();
              cmd.Parameters.Add(categoryIdParameter);

              SqlParameter taskIdParameter = new SqlParameter();
              taskIdParameter.ParameterName="@TaskId";
              taskIdParameter.Value=newTask.GetId();
              cmd.Parameters.Add(taskIdParameter);

              cmd.ExecuteNonQuery();
              if(conn != null)
              {
            conn.Close();
              }
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:22,代码来源:Category.cs

示例6: AddTask

        public void AddTask(Task newTask)
        {
            SqlConnection conn = DB.Connection();
              conn.Open();

              SqlDataReader rdrCheckForDuplicate = null;
              SqlCommand cmdCheckForDuplicate = new SqlCommand("SELECT * FROM categories_tasks WHERE [email protected] AND [email protected]", conn);
              SqlParameter categoryIdParameterCheckForDuplicate = new SqlParameter();
              categoryIdParameterCheckForDuplicate.ParameterName = "@CategoryId";
              categoryIdParameterCheckForDuplicate.Value = this.GetId();
              cmdCheckForDuplicate.Parameters.Add(categoryIdParameterCheckForDuplicate);

              SqlParameter taskIdParameterCheckForDuplicate = new SqlParameter();
              taskIdParameterCheckForDuplicate.ParameterName = "@TaskId";
              taskIdParameterCheckForDuplicate.Value = newTask.GetId();
              cmdCheckForDuplicate.Parameters.Add(taskIdParameterCheckForDuplicate);

              List<int> matchedJoins = new List<int> {};
              rdrCheckForDuplicate = cmdCheckForDuplicate.ExecuteReader();
              while(rdrCheckForDuplicate.Read())
              {
            matchedJoins.Add(rdrCheckForDuplicate.GetInt32(0));
              }

              if (rdrCheckForDuplicate != null) rdrCheckForDuplicate.Close();

              if (matchedJoins.Count == 0)
              {
            SqlCommand cmd = new SqlCommand("INSERT INTO categories_tasks (category_id, task_id) VALUES (@CategoryId, @TaskId)", conn);

            SqlParameter categoryIdParameter = new SqlParameter();
            categoryIdParameter.ParameterName = "@CategoryId";
            categoryIdParameter.Value = this.GetId();
            cmd.Parameters.Add(categoryIdParameter);

            SqlParameter taskIdParameter = new SqlParameter();
            taskIdParameter.ParameterName = "@TaskId";
            taskIdParameter.Value = newTask.GetId();
            cmd.Parameters.Add(taskIdParameter);

            cmd.ExecuteNonQuery();
              }
              if (conn != null)
              {
            conn.Close();
              }
        }
开发者ID:CharlesEwel,项目名称:csharp-todo-week4,代码行数:47,代码来源:Category.cs

示例7: Test_FindFindsTaskInDatabase

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

              //Act
              Task result = Task.Find(testTask.GetId());

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

示例8: Test_Find_FindsTaskInDatabase

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

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

              Task foundTask = Task.Find(testTask.GetId());

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


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