public static bool DeleteReminders(string connectionString, IEnumerable <Reminder> reminders) { try { using (var context = new ReminderDBContext(connectionString)) { foreach (var customer in reminders.Select(callReg => new Reminder() { ID = callReg.ID })) { context.Reminders.Attach(customer); context.Reminders.Remove(customer); } var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool AddReminder(string connectionString, Reminder reminder) { try { using (var context = new ReminderDBContext(connectionString)) { context.Reminders.Add(reminder); var result = context.SaveChanges(); return result > 0; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return false; } }
public static bool AddReminder(string connectionString, Reminder reminder) { try { using (var context = new ReminderDBContext(connectionString)) { context.Reminders.Add(reminder); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool DeleteReminders(string connectionString, IEnumerable<Reminder> reminders) { try { using (var context = new ReminderDBContext(connectionString)) { foreach (var customer in reminders.Select(callReg => new Reminder() { ID = callReg.ID })) { context.Reminders.Attach(customer); context.Reminders.Remove(customer); } var result = context.SaveChanges(); return result > 0; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return false; } }
public static bool UpdateReminders(string connectionString, IEnumerable <Reminder> reminders) { try { using (var context = new ReminderDBContext(connectionString)) { foreach (var reminder in reminders) { context.Reminders.Add(reminder); var entry = context.Entry(reminder); entry.State = EntityState.Modified; } var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static bool UpdateReminders(string connectionString, IEnumerable<Reminder> reminders) { try { using (var context = new ReminderDBContext(connectionString)) { foreach (var reminder in reminders) { context.Reminders.Add(reminder); var entry = context.Entry(reminder); entry.State = EntityState.Modified; } var result = context.SaveChanges(); return result > 0; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return false; } }