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