/// <summary> /// Permanentely deletes a single reminder from the database /// </summary> /// <param name="rem">The reminder you wish to remove</param> public static void PermanentelyDeleteReminder(Reminder rem) { using (RemindMeDbEntities db = new RemindMeDbEntities()) { db.Reminder.Attach(rem); db.Reminder.Remove(rem); DLAVRProperties.DeleteAvrFilesFoldersById(rem.Id); DLAVRProperties.DeleteAvrProperties(rem.Id); SaveAndCloseDataBase(db); } }
/// <summary> /// Deletes multiple reminders from the database. /// </summary> /// <param name="rems"></param> public static void PermanentelyDeleteReminders(List <Reminder> rems) { //We use this method so we can attach and remove the reminders in a foreach loop, and save changes to the database after the loop. //If you use the DeleteReminder method in a foreach loop, it will open and close the database each time using (RemindMeDbEntities db = new RemindMeDbEntities()) { foreach (Reminder rem in rems) { if (GetReminderById(rem.Id) != null) //Check if the reminder exists { db.Reminder.Attach(rem); db.Reminder.Remove(rem); } DLAVRProperties.DeleteAvrFilesFoldersById(rem.Id); DLAVRProperties.DeleteAvrProperties(rem.Id); } SaveAndCloseDataBase(db); } }