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 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 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 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;
            }
        }