public void UpdateTask(TaskModel task) { using (CapsuleEntities2 dbContext = new CapsuleEntities2()) { dbContext.Entry(task).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); } }
public void AddTask(TaskModel task) { using (CapsuleEntities2 dbContext = new CapsuleEntities2()) { dbContext.Tasks.Add(task); dbContext.SaveChanges(); } }
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(); } }