示例#1
0
        /// <summary>
        /// Finds all Reps that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type Rep.</returns>
        public override IEnumerable <Rep> Find(Expression <Func <Rep, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <Rep> .Decompile(predicate);

            Filter username  = filters.SingleOrDefault(x => x.PropertyName == "Username");
            Filter firstName = filters.SingleOrDefault(x => x.PropertyName == "FirstName");
            Filter lastName  = filters.SingleOrDefault(x => x.PropertyName == "LastName");
            Filter isActive  = filters.SingleOrDefault(x => x.PropertyName == "IsActive");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_Rep_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_Username", SqlDbType.VarChar, 202)
                {
                    Value = username == null ? DBNull.Value : username.Value
                });
                command.Parameters.Add(new SqlParameter("@p_FirstName", SqlDbType.VarChar, 12)
                {
                    Value = firstName == null ? DBNull.Value : firstName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_LastName", SqlDbType.VarChar, 22)
                {
                    Value = lastName == null ? DBNull.Value : lastName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsActive", SqlDbType.Bit, 1)
                {
                    Value = isActive == null ? DBNull.Value : isActive.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(Rep), reader, true) as Rep);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Finds all Periods that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type Period.</returns>
        public override IEnumerable <Period> Find(Expression <Func <Period, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <Period> .Decompile(predicate);

            Filter periodId   = filters.SingleOrDefault(x => x.PropertyName == "PeriodId");
            Filter periodDate = filters.SingleOrDefault(x => x.PropertyName == "StartDate");

            if (periodDate == null)
            {
                periodDate = filters.SingleOrDefault(x => x.PropertyName == "EndDate");
            }
            Filter periodIsOpen = filters.SingleOrDefault(x => x.PropertyName == "IsOpen");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_Period_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_PeriodId", SqlDbType.SmallInt, 10)
                {
                    Value = periodId == null ? DBNull.Value : periodId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodDate", SqlDbType.Date, 10)
                {
                    Value = periodDate == null ? DBNull.Value : periodDate.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsOpen", SqlDbType.Bit, 1)
                {
                    Value = periodIsOpen == null ? DBNull.Value : periodIsOpen.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(Period), reader, true) as Period);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Finds all Agents that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type Agent.</returns>
        public override IEnumerable <Agent> Find(Expression <Func <Agent, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <Agent> .Decompile(predicate);

            Filter agencyCode  = filters.SingleOrDefault(x => x.PropertyName == "AgencyCode");
            Filter agencyName  = filters.SingleOrDefault(x => x.PropertyName == "AgencyName");
            Filter activeAgent = filters.SingleOrDefault(x => x.PropertyName == "IsActiveAgent");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_Agent_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_AgencyCode", SqlDbType.NVarChar, 10)
                {
                    Value = agencyCode == null ? DBNull.Value : agencyCode.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgencyName", SqlDbType.NVarChar, 102)
                {
                    Value = agencyName == null ? DBNull.Value : agencyName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsActiveAgent", SqlDbType.Bit, 1)
                {
                    Value = activeAgent == null ? DBNull.Value : activeAgent.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(Agent), reader, true) as Agent);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Finds all Questions that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type Question.</returns>
        public override IEnumerable <Question> Find(Expression <Func <Question, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <Question> .Decompile(predicate);

            Filter questionType    = filters.SingleOrDefault(x => x.PropertyName == "QuestionTypeId");
            Filter periodId        = filters.SingleOrDefault(x => x.PropertyName == "PeriodId");
            Filter periodStartDate = filters.SingleOrDefault(x => x.PropertyName == "StartDate");
            Filter periodEndDate   = filters.SingleOrDefault(x => x.PropertyName == "EndDate");
            Filter periodIsOpen    = filters.SingleOrDefault(x => x.PropertyName == "IsOpen");
            Filter questionText    = filters.SingleOrDefault(x => x.PropertyName == "QuestionText");
            Filter questionSort    = filters.SingleOrDefault(x => x.PropertyName == "QuestionSort");
            Filter questionDesc    = filters.SingleOrDefault(x => x.PropertyName == "Description");
            Filter hasAnswers      = filters.SingleOrDefault(x => x.PropertyName == "HasAnswers");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_Question_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_QuestionType", SqlDbType.TinyInt, 3)
                {
                    Value = questionType == null ? DBNull.Value : questionType.Value
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodId", SqlDbType.SmallInt, 5)
                {
                    Value = periodId == null ? DBNull.Value : periodId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodStartDate", SqlDbType.DateTime)
                {
                    Value = periodStartDate == null ? DBNull.Value : Convert.ToDateTime(periodStartDate.Value).ToValidRange()
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodEndDate", SqlDbType.DateTime)
                {
                    Value = periodEndDate == null ? DBNull.Value : Convert.ToDateTime(periodEndDate.Value).ToValidRange()
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodIsOpen", SqlDbType.Bit, 1)
                {
                    Value = periodIsOpen == null ? DBNull.Value : periodIsOpen.Value
                });
                command.Parameters.Add(new SqlParameter("@p_QuestionText", SqlDbType.VarChar, 8000)
                {
                    Value = questionText == null ? DBNull.Value : questionText.Value
                });
                command.Parameters.Add(new SqlParameter("@p_QuestionSort", SqlDbType.Int, 10)
                {
                    Value = questionSort == null ? DBNull.Value : questionSort.Value
                });
                command.Parameters.Add(new SqlParameter("@p_QuestionDesc", SqlDbType.VarChar, 8000)
                {
                    Value = questionDesc == null ? DBNull.Value : questionDesc.Value
                });
                command.Parameters.Add(new SqlParameter("@p_HasAnswers", SqlDbType.Bit, 1)
                {
                    Value = hasAnswers == null ? DBNull.Value : hasAnswers.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(Question), reader, true) as Question);
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Finds all Contacts that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type Contact.</returns>
        public override IEnumerable <Contact> Find(Expression <Func <Contact, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <Contact> .Decompile(predicate);

            Filter firstName   = filters.SingleOrDefault(x => x.PropertyName == "FirstName");
            Filter middleName  = filters.SingleOrDefault(x => x.PropertyName == "MiddleName");
            Filter lastName    = filters.SingleOrDefault(x => x.PropertyName == "LastName");
            Filter phoneNumber = filters.SingleOrDefault(x => x.PropertyName == "PhoneNumber");
            Filter repNotes    = filters.SingleOrDefault(x => x.PropertyName == "RepNotes");
            Filter isPrimary   = filters.SingleOrDefault(x => x.PropertyName == "IsPrimary");
            Filter agentId     = filters.SingleOrDefault(x => x.PropertyName == "AgentId");
            Filter agentCode   = filters.SingleOrDefault(x => x.PropertyName == "AgencyCode");
            Filter agentName   = filters.SingleOrDefault(x => x.PropertyName == "AgencyName");
            Filter activeAgent = filters.SingleOrDefault(x => x.PropertyName == "IsActiveAgent");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_Contact_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_FirstName", SqlDbType.NVarChar, 202)
                {
                    Value = firstName == null ? DBNull.Value : firstName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_MiddleName", SqlDbType.NVarChar, 202)
                {
                    Value = middleName == null ? DBNull.Value : middleName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_LastName", SqlDbType.NVarChar, 202)
                {
                    Value = lastName == null ? DBNull.Value : lastName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_PhoneNumber", SqlDbType.NVarChar, 202)
                {
                    Value = phoneNumber == null ? DBNull.Value : phoneNumber.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepNotes", SqlDbType.NVarChar, 2002)
                {
                    Value = repNotes == null ? DBNull.Value : repNotes.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsPrimary", SqlDbType.Bit, 1)
                {
                    Value = isPrimary == null ? DBNull.Value : isPrimary.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgentId", SqlDbType.Int, 10)
                {
                    Value = agentId == null ? DBNull.Value : agentId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgencyCode", SqlDbType.VarChar, 10)
                {
                    Value = agentCode == null ? DBNull.Value : agentCode.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgencyName", SqlDbType.VarChar, 102)
                {
                    Value = agentName == null ? DBNull.Value : agentName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsActiveAgent", SqlDbType.Bit, 1)
                {
                    Value = activeAgent == null ? DBNull.Value : activeAgent.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(Contact), reader, true) as Contact);
                    }
                }
            }
        }
        /// <summary>
        /// Finds all AttemptLogs that satisfy the provided lambda expression.
        /// </summary>
        /// <param name="predicate">A lambda expression providing search criteria.</param>
        /// <returns>IEnumerable of type AttemptLog.</returns>
        public override IEnumerable <AttemptLog> Find(Expression <Func <AttemptLog, bool> > predicate)
        {
            List <Filter> filters = ExpressionDecompiler <AttemptLog> .Decompile(predicate);

            Filter periodId      = filters.SingleOrDefault(x => x.PropertyName == "PeriodId");
            Filter periodIsOpen  = filters.SingleOrDefault(x => x.PropertyName == "IsOpen");
            Filter agentId       = filters.SingleOrDefault(x => x.PropertyName == "AgentId");
            Filter agentCode     = filters.SingleOrDefault(x => x.PropertyName == "AgencyCode");
            Filter agentName     = filters.SingleOrDefault(x => x.PropertyName == "AgencyName");
            Filter activeAgent   = filters.SingleOrDefault(x => x.PropertyName == "IsActiveAgent");
            Filter repId         = filters.SingleOrDefault(x => x.PropertyName == "PeriodId");
            Filter repUsername   = filters.SingleOrDefault(x => x.PropertyName == "RepId");
            Filter repFirstName  = filters.SingleOrDefault(x => x.PropertyName == "FirstName");
            Filter repLastName   = filters.SingleOrDefault(x => x.PropertyName == "LastName");
            Filter repIsActive   = filters.SingleOrDefault(x => x.PropertyName == "IsActive");
            Filter attemptedDate = filters.SingleOrDefault(x => x.PropertyName == "AttemptedDate");
            Filter attemptedBy   = filters.SingleOrDefault(x => x.PropertyName == "AttemptedBy");

            using (IDbCommand command = Context.CreateCommand())
            {
                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = @"dbo.Survey_AttemptLog_Search";
                command.CommandTimeout = TimeOut;

                command.Parameters.Add(new SqlParameter("@p_PeriodId", SqlDbType.SmallInt, 5)
                {
                    Value = periodId == null ? DBNull.Value : periodId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_PeriodIsOpen", SqlDbType.Bit, 1)
                {
                    Value = periodIsOpen == null ? DBNull.Value : periodIsOpen.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgentId", SqlDbType.Int, 10)
                {
                    Value = agentId == null ? DBNull.Value : agentId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgencyCode", SqlDbType.VarChar, 10)
                {
                    Value = agentCode == null ? DBNull.Value : agentCode.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AgencyName", SqlDbType.VarChar, 102)
                {
                    Value = agentName == null ? DBNull.Value : agentName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_IsActiveAgent", SqlDbType.Bit, 1)
                {
                    Value = activeAgent == null ? DBNull.Value : activeAgent.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepId", SqlDbType.Int, 10)
                {
                    Value = repId == null ? DBNull.Value : repId.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepUsername", SqlDbType.VarChar, 202)
                {
                    Value = repUsername == null ? DBNull.Value : repUsername.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepFirstName", SqlDbType.VarChar, 12)
                {
                    Value = repFirstName == null ? DBNull.Value : repFirstName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepLastName", SqlDbType.VarChar, 22)
                {
                    Value = repLastName == null ? DBNull.Value : repLastName.Value
                });
                command.Parameters.Add(new SqlParameter("@p_RepIsActive", SqlDbType.Bit, 1)
                {
                    Value = repIsActive == null ? DBNull.Value : repIsActive.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AttemptedDate", SqlDbType.SmallInt, 10)
                {
                    Value = attemptedDate == null ? DBNull.Value : attemptedDate.Value
                });
                command.Parameters.Add(new SqlParameter("@p_AttemptedBy", SqlDbType.SmallInt, 10)
                {
                    Value = attemptedBy == null ? DBNull.Value : attemptedBy.Value
                });

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        yield return(MapEntity(typeof(AttemptLog), reader, true) as AttemptLog);
                    }
                }
            }
        }