コード例 #1
0
 public void UpdateTask(TaskModel task)
 {
     using (CapsuleEntities2 dbContext = new CapsuleEntities2())
     {
         dbContext.Entry(task).State = System.Data.Entity.EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
コード例 #2
0
 public void AddTask(TaskModel task)
 {
     using (CapsuleEntities2 dbContext = new CapsuleEntities2())
     {
         dbContext.Tasks.Add(task);
         dbContext.SaveChanges();
     }
 }
コード例 #3
0
 public void DeleteTask(int taskId)
 {
     using (CapsuleEntities2 dbContext = new CapsuleEntities2())
     {
         var task = dbContext.Tasks.Find(taskId);
         if (task != null)
         {
             dbContext.Tasks.Remove(task);
         }
         dbContext.SaveChanges();
     }
 }