コード例 #1
0
 public void Save(TaskItem newTask)
 {
     newTask.User = this.User;
     this.Database.Users.Attach(this.User);
     if (newTask.Id == 0)
     {
         newTask.Created = DateTime.UtcNow;
         this.Database.TaskItems.Add(newTask);
     }
     else
     {
         this.Database.TaskItems.Attach(newTask);
         this.Database.SetAsModified(newTask);
     }
     this.Database.SaveChanges();
 }
コード例 #2
0
        public void Test_TaskService_Add_Get()
        {
            var mockDatabase = CreateDatabaseMock();
            var user = new User() { Name = "Test user", Email = "*****@*****.**", Id = 1 };
            using (var taskService = ServiceFactory.CreateTaskService(user, mockDatabase.Object))
            {
                Assert.IsNotNull(taskService);

                var task = new Two10.TaskList.Model.TaskItem() { Name = "Get milk" };
                taskService.Save(task);
                var task2 = taskService.Get(task.Id);

                Assert.IsNotNull(task2);
                Assert.AreEqual(task, task2);
                Assert.AreEqual(user, task.User, "The service should associate the task with the user");
                Assert.AreEqual(1, taskService.AllTasks().Count());
            }
        }
コード例 #3
0
 public void Put(int id, TaskItem value)
 {
 }
コード例 #4
0
 public void Post(TaskItem value)
 {
 }