public void AddTask(Task newTaskItem) { studentusDB.TaskItems.InsertOnSubmit(newTaskItem); AllTaskItems.Add(newTaskItem); studentusDB.SubmitChanges(); }
public void DeleteTaskItem(Task taskForDelete) { // Remove the to-do item from the "all" observable collection. AllTaskItems.Remove(taskForDelete); // Remove the to-do item from the data context. studentusDB.TaskItems.DeleteOnSubmit(taskForDelete); // Save changes to the database. studentusDB.SubmitChanges(); }
private void NewTask_Click(object sender, EventArgs e) { taskName.Text = taskName.Text.Trim(); if (taskName.Text == "") { MessageBox.Show("Please enter a name for your new task."); return; } Task taskToAdd = new Task { NazivZadatka = taskName.Text, OpisZadatka = taskDescription.Text, //PocetakZadatka = (DateTime)startTask.Value, DeadLine = (DateTime)deadLine.Value, OznakaPredmeta = subjectCurrentID }; App.ViewModel.AddTask(taskToAdd); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); }