public void DeleteItem(int id) //Delete an item { ToDoItem delItem = itemContext.ToDoItems.Where(x => x.Id == id).FirstOrDefault(); itemContext.Remove(delItem); itemContext.SaveChanges(); }
public void DeleteItem(int id) { ToDoItem findItem = context.ToDoItems.Where(item => item.Id == id).FirstOrDefault(); context.Remove(findItem); context.SaveChanges(); }
public void DeleteItem(int ItemID) { //LINQ handles finding entry by matching ID given from user and what's in the dataset //Removes the item selected from dataset //saves the changes to the dataset ToDoItem DeleteItem = context.ToDoList.Where(x => x.ID == ItemID).FirstOrDefault(); context.Remove(DeleteItem); context.SaveChanges(); }
public void DeleteItem(int ItemID) { //LINQ finds entry by matching ID entered by user with information in dataset //Removes the correct item from dataset //Saves changes to the dataset ToDoItem DeleteItem = context.ToDoList.Where(x => x.ID == ItemID).FirstOrDefault(); context.Remove(DeleteItem); context.SaveChanges(); }
public void RemoveItem(int id) { ToDoItem deleteItem = itemContext.ToDoItem.Where(x => x.Id == id).FirstOrDefault(); if (deleteItem != null) { itemContext.Remove(deleteItem); itemContext.SaveChanges(); } // Create an if else statement to check if the number given is a valid ID of a TODO item, if not null remove if null do nothing. }
/// <summary> /// Uses IDPrompt return to get the ID of the task to be deleted. /// Deletes the task. /// </summary> public static void DeleteTask() { ToDoItem DeleteTask = context.ToDoList.Where(x => x.ID == IDPrompt()).FirstOrDefault(); if (DeleteTask != null) { context.Remove(DeleteTask); context.SaveChanges(); DoneReply(); } else { FailReply(); } }
public static string DeleteItem(int item) // removes item from db { string result; ToDoItem deleteItem = context.ToDoItems.Where(x => x.Id == item).FirstOrDefault(); //find selected item by id if (deleteItem != null) // if found { context.Remove(deleteItem); //remove item context.SaveChanges(); //commit changes result = "Item Deleted!"; //message } else { result = "Item not found!"; //message } return(result); //return message }
public void DeleteItem(ToDoItem item) { context.Remove(item); context.SaveChanges(); }