Beispiel #1
0
        public List <AdminBO> GetAdminInfoByOrgKey(string gOrgKeyEncrypted)
        {
            List <AdminBO> AdminList = new List <AdminBO>();

            int OrgId      = 0;
            int AdminOrgId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var OrgQuery = (from response in Context.Organizations
                                    where response.OrganizationKey == gOrgKeyEncrypted
                                    select new { response.OrganizationId }).First();

                    OrgId = OrgQuery.OrganizationId;



                    var AdminOrgQuery = (from response in Context.Organizations
                                         where response.IsHostOrganization == true
                                         select new { response.OrganizationId }).First();
                    AdminOrgId = AdminOrgQuery.OrganizationId;


                    var AdminQuery = (from response in Context.Admins
                                      where response.OrganizationId == OrgId && response.IsActive == true && response.Notify == true
                                      select new { response });
                    var AdminQuery1 = (from response in Context.Admins
                                       where  response.OrganizationId == AdminOrgId && response.IsActive == true && response.Notify == true
                                       select new { response });

                    foreach (var row in AdminQuery)
                    {
                        AdminBO AdminBO = new AdminBO();
                        AdminBO.AdminEmail = row.response.AdminEmail;
                        AdminBO.IsActive   = row.response.IsActive;

                        AdminList.Add(AdminBO);
                    }
                    foreach (var row in AdminQuery1)
                    {
                        AdminBO AdminBO = new AdminBO();
                        AdminBO.AdminEmail = row.response.AdminEmail;
                        AdminBO.IsActive   = row.response.IsActive;

                        AdminList.Add(AdminBO);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }



            return(AdminList);
        }
Beispiel #2
0
        /// <summary>
        /// Gets SurveyInfo based on a list of ids
        /// </summary>
        /// <param name="SurveyInfoId">Unique SurveyInfo identifier.</param>
        /// <returns>SurveyInfo.</returns>
        public List <SurveyInfoBO> GetSurveyInfo(List <string> SurveyInfoIdList, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            if (SurveyInfoIdList.Count > 0)
            {
                try
                {
                    foreach (string surveyInfoId in SurveyInfoIdList.Distinct())
                    {
                        Guid Id = new Guid(surveyInfoId);

                        using (var Context = DataObjectFactory.CreateContext())
                        {
                            result.Add(Mapper.Map(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id)));
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }
            else
            {
                try
                {
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        result = Mapper.Map(Context.SurveyMetaDatas.ToList());
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            // remove the items to skip
            // remove the items after the page size
            if (PageNumber > 0 && PageSize > 0)
            {
                result.Sort(CompareByDateCreated);
                // remove the items to skip
                if (PageNumber * PageSize - PageSize > 0)
                {
                    result.RemoveRange(0, PageSize);
                }

                if (PageNumber * PageSize < result.Count)
                {
                    result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
                }
            }

            return(result);
        }
Beispiel #3
0
        public void InsertAdmin(AdminBO Admin)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Admin AdminEntity = Mapper.ToEF(Admin);



                    Context.AddToAdmins(AdminEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }



            // Get Admin Id
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from _Admin in Context.Admins
                                 where _Admin.AdminEmail == Admin.AdminEmail && _Admin.FirstName == Admin.FirstName && Admin.LastName == _Admin.LastName
                                 select new { _Admin.AdminId }).Distinct();


                    var DataRow = Query.Distinct();
                    foreach (var Row in DataRow)
                    {
                        Admin.AdminId = Row.AdminId;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            // Insert Address
            using (var Context = DataObjectFactory.CreateContext())
            {
                Address AddressEntity = Mapper.ToAddressEF(Admin);



                Context.AddToAddresses(AddressEntity);

                Context.SaveChanges();
            }
        }
Beispiel #4
0
        public void ValidateServername(SurveyInfoBO pRequestMessage)
        {
            var    Context      = DataObjectFactory.CreateContext();
            string eweAdostring = Context.Connection.ConnectionString.Substring(Context.Connection.ConnectionString.ToLower().IndexOf("data source="), Context.Connection.ConnectionString.Substring(Context.Connection.ConnectionString.ToLower().IndexOf("data source=")).IndexOf(";"));

            string epiDBstring = pRequestMessage.DBConnectionString.Substring(0, pRequestMessage.DBConnectionString.IndexOf(";"));

            if (eweAdostring.ToLower() != epiDBstring.ToLower())
            {
                pRequestMessage.IsSqlProject = false;
            }
        }
Beispiel #5
0
        public List <SurveyInfoBO> GetSurveyInfoByOrgKey(string SurveyId, string Okey)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == Okey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            if (!string.IsNullOrEmpty(SurveyId))
            {
                try
                {
                    Guid Id = new Guid(SurveyId);
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        responseList.Add(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id && x.OrganizationId == OrganizationId));
                        if (responseList[0] != null)
                        {
                            result = Mapper.Map(responseList);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }

            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Inserts a new Organization.
        /// </summary>
        /// <remarks>
        /// Following insert, Organization object will contain the new identifier.
        /// </remarks>
        /// <param name="Organization">Organization.</param>
        public void InsertOrganization(OrganizationBO Organization)
        {
            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Organization OrganizationEntity = Mapper.ToEF(Organization);
                    Context.AddToOrganizations(OrganizationEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #7
0
        public List <SurveyInfoBO> GetAllSurveysByOrgKey(string Okey)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = (from response in Context.Organizations
                                 where response.OrganizationKey == Okey
                                 select response).SingleOrDefault();

                    if (Query != null)
                    {
                        OrganizationId = Query.OrganizationId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    responseList = Context.SurveyMetaDatas.Where(x => x.OrganizationId == OrganizationId).ToList();
                    if (responseList.Count() > 0 && responseList[0] != null)
                    {
                        result = Mapper.Map(responseList);
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            return(result);
        }
Beispiel #8
0
        public void InsertConnectionString(DbConnectionStringBO ConnectionString)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    //Context.usp_AddDatasource(ConnectionString.DatasourceServerName, ConnectionString.DatabaseType, ConnectionString.InitialCatalog, ConnectionString.PersistSecurityInfo, ConnectionString.DatabaseUserID, ConnectionString.SurveyId, ConnectionString.Password);

                    //Context.SaveChanges();
                    Context.AddToEIDatasources(Mapper.Map(ConnectionString));
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Gets a specific SurveyResponse.
        /// </summary>
        /// <param name="SurveyResponseId">Unique SurveyResponse identifier.</param>
        /// <returns>SurveyResponse.</returns>
        public List <SurveyResponseBO> GetSurveyResponse(List <string> SurveyResponseIdList, Guid UserPublishKey, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyResponseBO> result = new List <SurveyResponseBO>();

            if (SurveyResponseIdList.Count > 0)
            {
                foreach (string surveyResponseId in SurveyResponseIdList.Distinct())
                {
                    Guid Id = new Guid(surveyResponseId);

                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        result.Add(Mapper.Map(Context.SurveyResponses.FirstOrDefault(x => x.ResponseId == Id)));
                    }
                }
            }
            else
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    result = Mapper.Map(Context.SurveyResponses.ToList());
                }
            }

            if (PageNumber > 0 && PageSize > 0)
            {
                result.Sort(CompareByDateCreated);
                // remove the items to skip
                if (PageNumber * PageSize - PageSize > 0)
                {
                    result.RemoveRange(0, PageSize);
                }

                if (PageNumber * PageSize < result.Count)
                {
                    result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
                }
            }


            return(result);
        }
Beispiel #10
0
        public void InsertAdminInfo(AdminBO Admin)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Admin AdminEntity = Mapper.ToEF(Admin);



                    Context.AddToAdmins(AdminEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Updates a Organization.
        /// </summary>
        /// <param name="Organization">Organization.</param>
        public void UpdateOrganization(OrganizationBO Organization)
        {
            ////Update Survey
            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.Organizations
                                where response.OrganizationKey == Organization.OrganizationKey
                                select response;

                    var DataRow = Query.Single();
                    DataRow.Organization1 = Organization.Organization;

                    DataRow.IsEnabled = Organization.IsEnabled;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Updates a SurveyInfo.
        /// </summary>
        /// <param name="SurveyInfo">SurveyInfo.</param>
        public void UpdateSurveyInfo(SurveyInfoBO SurveyInfo)
        {
            try
            {
                Guid Id = new Guid(SurveyInfo.SurveyId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyMetaDatas
                                where response.SurveyId == Id
                                select response;

                    var DataRow = Query.Single();
                    DataRow.SurveyName       = SurveyInfo.SurveyName;
                    DataRow.SurveyNumber     = SurveyInfo.SurveyNumber;
                    DataRow.TemplateXML      = SurveyInfo.XML;
                    DataRow.IntroductionText = SurveyInfo.IntroductionText;
                    DataRow.ExitText         = SurveyInfo.ExitText;
                    DataRow.OrganizationName = SurveyInfo.OrganizationName;
                    DataRow.DepartmentName   = SurveyInfo.DepartmentName;
                    DataRow.ClosingDate      = SurveyInfo.ClosingDate;
                    DataRow.SurveyTypeId     = SurveyInfo.SurveyType;
                    DataRow.UserPublishKey   = SurveyInfo.UserPublishKey;
                    DataRow.TemplateXMLSize  = RemoveWhitespace(SurveyInfo.XML).Length;
                    DataRow.IsDraftMode      = SurveyInfo.IsDraftMode;
                    DataRow.StartDate        = SurveyInfo.StartDate;
                    DataRow.LastUpdate       = DateTime.Now;
                    DataRow.IsSQLProject     = SurveyInfo.IsSqlProject;

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #13
0
        public void UpdateConnectionString(DbConnectionStringBO ConnectionString)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from DataSource in Context.EIDatasources
                                where DataSource.SurveyId == ConnectionString.SurveyId
                                select DataSource;

                    var DataRow = Query.Single();
                    DataRow = Mapper.Map(ConnectionString);



                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Inserts a new ErrorLog.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="pValue">ErrorText.</param>
        public void InsertErrorLog(Dictionary <string, string> pValue)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    ErrorLog ErrorLogEntity = new ErrorLog();
                    ErrorLogEntity.ErrorDate = DateTime.Now;
                    ErrorLogEntity.Comment   = "SurveyAPI Error";
                    StringBuilder ErrText = new StringBuilder();
                    foreach (KeyValuePair <string, string> kvp in  pValue)
                    {
                        if (kvp.Key == "SurveyId")
                        {
                            ErrorLogEntity.SurveyId = new Guid(kvp.Value.ToString());
                        }
                        else if (kvp.Key == "ResponseId")
                        {
                            ErrorLogEntity.ResponseId = new Guid(kvp.Value.ToString());
                        }
                        else
                        {
                            ErrText.Append(" " + kvp.Key + " " + kvp.Value + ". ");
                        }
                    }
                    ErrorLogEntity.ErrorText = ErrText.ToString();

                    Context.AddToErrorLogs(ErrorLogEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Gets a specific Organization.
        /// </summary>
        /// <param name="OrganizationId">Unique Organization identifier.</param>
        /// <returns>Organization.</returns>
        public List <OrganizationBO> GetOrganizationKeys(string OrganizationName)
        {
            List <OrganizationBO> OrganizationBO = new  List <OrganizationBO>();

            try{
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.Organizations
                                where response.Organization1 == OrganizationName
                                select response;

                    var DataRow = Query;
                    foreach (var Row in DataRow)
                    {
                        OrganizationBO.Add(Mapper.Map(Row));
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(OrganizationBO);
        }
Beispiel #16
0
        /// <summary>
        /// Inserts a new SurveyResponse.
        /// </summary>
        /// <remarks>
        /// Following insert, SurveyResponse object will contain the new identifier.
        /// </remarks>
        /// <param name="SurveyResponse">SurveyResponse.</param>
        public void InsertSurveyResponse(SurveyResponseBO SurveyResponse)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyResponse SurveyResponseEntity = Mapper.ToEF(SurveyResponse);
                    try
                    {
                        // SurveyResponseEntity.RecordSourceId = Context.lk_RecordSource.Where(u => u.RecordSource == "EIWS").Select(u => u.RecordSourceId).SingleOrDefault();
                    }
                    catch (Exception)
                    {
                    }
                    Context.AddToSurveyResponses(SurveyResponseEntity);

                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #17
0
        public UserAuthenticationResponseBO GetAuthenticationResponse(UserAuthenticationRequestBO UserAuthenticationRequestBO)
        {
            UserAuthenticationResponseBO UserAuthenticationResponseBO = Mapper.ToAuthenticationResponseBO(UserAuthenticationRequestBO);

            try
            {
                Guid Id = new Guid(UserAuthenticationRequestBO.ResponseId);


                using (var Context = DataObjectFactory.CreateContext())
                {
                    SurveyResponse surveyResponse = Context.SurveyResponses.First(x => x.ResponseId == Id);
                    if (surveyResponse != null)
                    {
                        UserAuthenticationResponseBO.PassCode = surveyResponse.ResponsePasscode;
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(UserAuthenticationResponseBO);
        }
Beispiel #18
0
        public void UpdatePassCode(UserAuthenticationRequestBO passcodeBO)
        {
            try
            {
                Guid Id = new Guid(passcodeBO.ResponseId);

                //Update Survey
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Query = from response in Context.SurveyResponses
                                where response.ResponseId == Id
                                select response;

                    var DataRow = Query.Single();

                    DataRow.ResponsePasscode = passcodeBO.PassCode;
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Gets SurveyResponses depending on criteria.
        /// </summary>
        /// <param name="SurveyResponseId">Unique SurveyResponse identifier.</param>
        /// <returns>SurveyResponse.</returns>
        public List <SurveyResponseBO> GetSurveyResponse(List <string> SurveyAnswerIdList, string pSurveyId, DateTime pDateCompleted, bool pIsDraftMode = false, int pStatusId = -1, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyResponseBO>        Finalresult = new List <SurveyResponseBO>();
            IEnumerable <SurveyResponseBO> result;
            List <SurveyResponse>          responseList = new List <SurveyResponse>();

            if (SurveyAnswerIdList.Count > 0)
            {
                foreach (string surveyResponseId in SurveyAnswerIdList.Distinct())
                {
                    try
                    {
                        Guid Id = new Guid(surveyResponseId);


                        using (var Context = DataObjectFactory.CreateContext())
                        {
                            SurveyResponse surveyResponse = Context.SurveyResponses.First(x => x.ResponseId == Id);
                            if (surveyResponse != null)
                            {
                                responseList.Add(surveyResponse);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                }
            }
            else
            {
                try{
                    using (var Context = DataObjectFactory.CreateContext())
                    {
                        if (!string.IsNullOrEmpty(pSurveyId))
                        {
                            Guid Id = new Guid(pSurveyId);
                            // responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id).ToList();
                            //if (pStatusId>0)
                            //{
                            //responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id && x.StatusId == pStatusId && x.IsDraftMode == pIsDraftMode).OrderBy(x=>x.DateCompleted).ToList();
                            //}
                            //else{
                            //    pStatusId = -1;
                            //    responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id && x.StatusId != 4 && x.IsDraftMode == pIsDraftMode).OrderBy(x => x.DateCompleted).ToList();

                            //}
                            // New client Epi info version 7.2
                            if (pStatusId == 0) // All 2,3,and 4 if available
                            {
                                responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id && x.IsDraftMode == pIsDraftMode).OrderBy(x => x.DateCompleted).ToList();
                            }
                            if (pStatusId == 3) // Only 3
                            {
                                responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id && x.StatusId == pStatusId && x.IsDraftMode == pIsDraftMode).OrderBy(x => x.DateCompleted).ToList();
                            }
                            if (pStatusId == 4) //   3 and 4
                            {
                                responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id && (x.StatusId == pStatusId || x.StatusId == 3) && x.IsDraftMode == pIsDraftMode).OrderBy(x => x.DateCompleted).ToList();
                            }
                            // Old client Epi info version 7.1.5.2
                            if (pStatusId == -1) // All 2,3,and 4 if available
                            {
                                responseList = Context.SurveyResponses.Where(x => x.SurveyId == Id).OrderBy(x => x.DateCompleted).ToList();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
            }


            //if(! string.IsNullOrEmpty(pSurveyId))
            //{
            //    Guid Id = new Guid(pSurveyId);
            //    List<SurveyResponse> surveyList = new List<SurveyResponse>();
            //    surveyList.AddRange(responseList.Where(x => x.SurveyId == Id));
            //    responseList = surveyList;
            //}

            //if (pStatusId > -1)
            //{
            //    List<SurveyResponse> statusList = new List<SurveyResponse>();
            //    statusList.AddRange(responseList.Where(x => x.StatusId == pStatusId));
            //    responseList = statusList;
            //}

            if (pDateCompleted > DateTime.MinValue)
            {
                List <SurveyResponse> dateList = new List <SurveyResponse>();

                //dateList.AddRange(responseList.Where(x => x.DateCompleted.Value.Month ==  pDateCompleted.Month && x.DateCompleted.Value.Year == pDateCompleted.Year && x.DateCompleted.Value.Day == pDateCompleted.Day));
                dateList.AddRange(responseList.Where(x => x.DateCompleted != null && x.DateCompleted.Value.Month == pDateCompleted.Month && x.DateCompleted.Value.Year == pDateCompleted.Year && x.DateCompleted.Value.Day == pDateCompleted.Day));
                responseList = dateList;
            }



            //if (PageNumber > 0 && PageSize > 0)
            //{
            //    result.Sort(CompareByDateCreated);
            //    // remove the items to skip
            //    if (PageNumber * PageSize - PageSize > 0)
            //    {
            //        result.RemoveRange(0, PageSize);
            //    }

            //    if (PageNumber * PageSize < result.Count)
            //    {
            //        result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
            //    }
            //}

            if (PageSize != -1 && PageNumber != -1)
            {
                result = Mapper.Map(responseList);
                result = result.Skip((PageNumber - 1) * PageSize).Take(PageSize);
                foreach (var item in result)
                {
                    Finalresult.Add(item);
                }
                return(Finalresult);
            }
            else
            {
                Finalresult = Mapper.Map(responseList);


                return(Finalresult);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Gets SurveyInfo based on criteria
        /// </summary>
        /// <param name="SurveyInfoId">Unique SurveyInfo identifier.</param>
        /// <returns>SurveyInfo.</returns>
        public List <SurveyInfoBO> GetSurveyInfo(List <string> SurveyInfoIdList, DateTime pClosingDate, string pOrganizationKey, int pSurveyType = -1, int PageNumber = -1, int PageSize = -1)
        {
            List <SurveyInfoBO> result = new List <SurveyInfoBO>();

            List <SurveyMetaData> responseList = new List <SurveyMetaData>();

            int OrganizationId = 0;

            try {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    OrganizationId = Context.Organizations.FirstOrDefault(x => x.OrganizationKey == pOrganizationKey).OrganizationId;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            if (SurveyInfoIdList.Count > 0)
            {
                foreach (string surveyInfoId in SurveyInfoIdList.Distinct())
                {
                    Guid Id = new Guid(surveyInfoId);
                    try{
                        using (var Context = DataObjectFactory.CreateContext())
                        {
                            responseList.Add(Context.SurveyMetaDatas.FirstOrDefault(x => x.SurveyId == Id && x.OrganizationId == OrganizationId));
                        }
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                }
            }
            else
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    responseList = Context.SurveyMetaDatas.ToList();
                }
            }


            if (responseList.Count > 0 && responseList[0] != null)
            {
                if (pSurveyType > -1)
                {
                    List <SurveyMetaData> statusList = new List <SurveyMetaData>();
                    statusList.AddRange(responseList.Where(x => x.SurveyTypeId == pSurveyType));
                    responseList = statusList;
                }

                if (OrganizationId > 0)
                {
                    List <SurveyMetaData> OIdList = new List <SurveyMetaData>();
                    OIdList.AddRange(responseList.Where(x => x.OrganizationId == OrganizationId));
                    responseList = OIdList;
                }

                if (pClosingDate != null)
                {
                    if (pClosingDate > DateTime.MinValue)
                    {
                        List <SurveyMetaData> dateList = new List <SurveyMetaData>();

                        dateList.AddRange(responseList.Where(x => x.ClosingDate.Month >= pClosingDate.Month && x.ClosingDate.Year >= pClosingDate.Year && x.ClosingDate.Day >= pClosingDate.Day));
                        responseList = dateList;
                    }
                }
                result = Mapper.Map(responseList);

                // remove the items to skip
                // remove the items after the page size
                if (PageNumber > 0 && PageSize > 0)
                {
                    result.Sort(CompareByDateCreated);

                    if (PageNumber * PageSize - PageSize > 0)
                    {
                        result.RemoveRange(0, PageSize);
                    }

                    if (PageNumber * PageSize < result.Count)
                    {
                        result.RemoveRange(PageNumber * PageSize, result.Count - PageNumber * PageSize);
                    }
                }
            }
            return(result);
        }