public static bool DeleteCallRegistries(string connectionString, IEnumerable <CallRegistry> callRegistries) { try { using (var context = new CallRegistryDBContext(connectionString)) { foreach (var customer in callRegistries.Select(callReg => new CallRegistry() { ID = callReg.ID })) { context.CallRegistries.Attach(customer); context.CallRegistries.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 CallRegistryCollection GetCallRegistries(string connectionString, string searchName, DateTime?callDate) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); IQueryable <CallRegistry> items = null; if (callDate.HasValue && !string.IsNullOrEmpty(searchName)) { items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value) && x.Name.Contains(searchName)); } else if (!string.IsNullOrEmpty(searchName)) { items = context.CallRegistries.Where(x => x.Name.Contains(searchName)); } else if (callDate.HasValue) { items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value)); } else { items = context.CallRegistries; } if (items != null) { foreach (var callReg in items) { callRegCollection.Add(callReg); } } return(new CallRegistryCollection(callRegCollection.ObservableList.OrderByDescending(x => x.CallDate).ToList())); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static bool AddCallLog(string connectionString, CallRegistry callRegistry) { try { using (var context = new CallRegistryDBContext(connectionString)) { context.CallRegistries.Add(callRegistry); var result = context.SaveChanges(); return result > 0; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return false; } }
public static bool AddCallLog(string connectionString, CallRegistry callRegistry) { try { using (var context = new CallRegistryDBContext(connectionString)) { context.CallRegistries.Add(callRegistry); var result = context.SaveChanges(); return(result > 0); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(false); } }
public static CallRegistryCollection GetCallRegistries(string connectionString, DateTime?callDate) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); var items = context.CallRegistries.Where(x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value.Date)); foreach (var callReg in items) { callRegCollection.Add(callReg); } return(callRegCollection); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static CallRegistryCollection GetCallRegistries(string connectionString) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); foreach (var callReg in context.CallRegistries) { callRegCollection.Add(callReg); } return(callRegCollection); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return(null); } }
public static bool DeleteCallRegistries(string connectionString, IEnumerable<CallRegistry> callRegistries) { try { using (var context = new CallRegistryDBContext(connectionString)) { foreach (var customer in callRegistries.Select(callReg => new CallRegistry() {ID = callReg.ID})) { context.CallRegistries.Attach(customer); context.CallRegistries.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 UpdateCallRegistries(string connectionString, IEnumerable <CallRegistry> callRegistries) { try { using (var context = new CallRegistryDBContext(connectionString)) { foreach (var callReg in callRegistries) { context.CallRegistries.Add(callReg); var entry = context.Entry(callReg); 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 CallRegistryCollection GetCallRegistries(string connectionString, DateTime? callDate) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); var items = context.CallRegistries.Where(x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value.Date)); foreach (var callReg in items) callRegCollection.Add(callReg); return callRegCollection; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return null; } }
public static bool UpdateCallRegistries(string connectionString, IEnumerable<CallRegistry> callRegistries) { try { using (var context = new CallRegistryDBContext(connectionString)) { foreach (var callReg in callRegistries) { context.CallRegistries.Add(callReg); var entry = context.Entry(callReg); 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 CallRegistryCollection GetCallRegistries(string connectionString) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); foreach (var callReg in context.CallRegistries) callRegCollection.Add(callReg); return callRegCollection; } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return null; } }
public static CallRegistryCollection GetCallRegistries(string connectionString, string searchName, DateTime? callDate) { try { using (var context = new CallRegistryDBContext(connectionString)) { var callRegCollection = new CallRegistryCollection(); IQueryable<CallRegistry> items = null; if (callDate.HasValue && !string.IsNullOrEmpty(searchName)) items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value) && x.Name.Contains(searchName)); else if (!string.IsNullOrEmpty(searchName)) items = context.CallRegistries.Where(x => x.Name.Contains(searchName)); else if (callDate.HasValue) { items = context.CallRegistries.Where( x => EntityFunctions.TruncateTime(x.CallDate) == EntityFunctions.TruncateTime(callDate.Value)); } else { items = context.CallRegistries; } if (items != null) foreach (var callReg in items) callRegCollection.Add(callReg); return new CallRegistryCollection(callRegCollection.ObservableList.OrderByDescending(x => x.CallDate).ToList()); } } catch (Exception exception) { NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail); return null; } }