示例#1
0
 public void EditTask(TaskObj task)
 {
     using (var db = new TodoListEntities1())
     {
         var selectedTask = db.Tasks.FirstOrDefault(x => x.TaskId == task.TaskId);
         selectedTask = task;
         db.Tasks.AddOrUpdate(selectedTask);
         db.SaveChanges();
     }
 }
示例#2
0
        public void DeleteTask(string taskId)
        {
            int taskIdToDelete = int.Parse(taskId);

            using (var db = new TodoListEntities1())
            {
                var deleteTask = db.Tasks.FirstOrDefault(x => x.TaskId == taskIdToDelete);
                db.Tasks.Remove(deleteTask);
                db.SaveChanges();
            }
        }
示例#3
0
        public void AddTask(TaskObj task)
        {
            Task newTask = new Task
            {
                Title   = task.Title,
                Details = task.Details,
                Date    = task.Date
            };

            using (var db = new TodoListEntities1())
            {
                db.Tasks.Add(newTask);
                db.SaveChanges();
            }
        }