Esempio n. 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();
     }
 }
Esempio n. 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();
            }
        }
Esempio n. 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();
            }
        }