/// Function Header*******************************************************
        /// Function Name: SaveHotSectionDetails
        /// Function Type: Function
        /// Functionality: used to save the details  
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void DeleteHotSectionDetails(int _intHotSectionDetailsId)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                var _varHotSections = _db.HotSectionDetails.Where(x => x.intHotSectionId.Equals(_intHotSectionDetailsId)).SingleOrDefault();
                _varHotSections.chrIsDeleted = 'Y';
                _varHotSections.dtDeletedOn = DateTime.Now;
                _db.SubmitChanges();

                _varHotSections = null;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateQuestionnaireDetails
        /// Function Type: Function
        /// Functionality: used to update the details 
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void DeleteFAQTopicDetails(int _intFAQTopicId)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                var oFaqTopic = _db.FaqTopics.Where(x => x.int_FAQTopicId.Equals(_intFAQTopicId)).FirstOrDefault();
                if (oFaqTopic != null)
                {
                    var _varFAQ = _db.FAQs.Where(x => x.strHeading.ToLower().Equals(oFaqTopic.strFaqTopic.ToLower())).ToList();
                    foreach (var item in _varFAQ)
                    {
                        item.chrisDeleted = 'Y';
                        item.dtDeletedOn = oFaqTopic.dtDeletedOn;
                        _db.SubmitChanges();
                    }

                    oFaqTopic.chrIsDeleted = 'Y';
                    oFaqTopic.dtDeletedOn = DateTime.Now;
                    _db.SubmitChanges();

                    oFaqTopic = null;
                }
            }
        }
 /// Function Header*******************************************************
 /// Function Name: SaveNewsletter
 /// Function Type: Function
 /// Functionality: used to save the details of newsletters
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void DeleteNewsletter(int _intNewsLetterId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var _varDup = _db.Newsletters.Where(x => x.intNewsLetterId.Equals(_intNewsLetterId)
                            ).SingleOrDefault();
         if (_varDup != null)
         {
             _varDup.chrIsDeleted = 'Y';
             _varDup.dtDeletedOn = DateTime.Now;
             _db.SubmitChanges();
         }
     }
 }
 /// Function Header*******************************************************
 /// Function Name: UpdateQuestionnaireDetails
 /// Function Type: Function
 /// Functionality: used to update the details 
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void DeleteEventDetails(int _intEventdId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var oVarObj = _db.Events.Where(x => x.intEventsId.Equals(_intEventdId)
                            ).SingleOrDefault();
         if (oVarObj != null)
         {
             oVarObj.chrIsDeleted = 'Y';
             oVarObj.dtDeletedOn = DateTime.Now;
             _db.SubmitChanges();
             oVarObj = null;
         }
     }
 }
 /// Function Header*******************************************************
 /// Function Name: ActivateDeactivateEvent
 /// Function Type: Function
 /// Functionality: used to update the activation and deactivation 
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void ActivateDeactivateEvent(int _intEventId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var oVarObj = _db.Events.Where(x => x.intEventsId.Equals(_intEventId)
                            ).SingleOrDefault();
         if (oVarObj != null)
         {
             oVarObj.chrIsActive = oVarObj.chrIsActive.Equals('Y') ? 'N' : 'Y';
             oVarObj.dtModifiedOn = DateTime.Now;
             _db.SubmitChanges();
             oVarObj = null;
         }
     }
 }
 /// Function Header*******************************************************
 /// Function Name: UpdateQuestionnaireDetails
 /// Function Type: Function
 /// Functionality: used to update the details 
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void ChangeStatusofQuestionnaire(int _intQuestionnareId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var oQuestionnaireDAL = _db.Questionnaires.Where(x => x.intQuestionnaireId.Equals(_intQuestionnareId)
                            ).SingleOrDefault();
         if (oQuestionnaireDAL != null)
         {
             oQuestionnaireDAL.chrIsActive = oQuestionnaireDAL.chrIsActive.Equals('Y') ? 'N' : 'Y';
             oQuestionnaireDAL.dtModifiedDate = DateTime.Now;
             _db.SubmitChanges();
             oQuestionnaireDAL = null;
         }
     }
 }
 /// Function Header*******************************************************
 /// Function Name: UpdateQuestionnaireDetails
 /// Function Type: Function
 /// Functionality: used to update the details 
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void DeleteQuestionnaireDetails(int _intQuestionnareId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var oQuestionnaireDAL = _db.Questionnaires.Where(x => x.intQuestionnaireId.Equals(_intQuestionnareId)
                            ).SingleOrDefault();
         if (oQuestionnaireDAL != null)
         {
             oQuestionnaireDAL.chrIsDeleted = 'Y';
             oQuestionnaireDAL.dtDeletedDate = DateTime.Now;
             _db.SubmitChanges();
             oQuestionnaireDAL = null;
         }
     }
 }
 /// Function Header*******************************************************
 /// Function Name: ActivateDeactivateEvent
 /// Function Type: Function
 /// Functionality: used to update the activation and deactivation 
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void ApproveDisapproveEvent(int _intEventId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var oVarObj = _db.Events.Where(x => x.intEventsId.Equals(_intEventId)
                            ).SingleOrDefault();
         if (oVarObj != null)
         {
             oVarObj.chrStatus = oVarObj.chrStatus.Equals('A') ? 'D' : 'A';
             oVarObj.dtModifiedOn = DateTime.Now;
             _db.SubmitChanges();
             oVarObj = null;
         }
     }
 }
        /// Function Header*******************************************************
        /// Function Name: DeleteNewsAnnouncements
        /// Function Type: Function
        /// Functionality: used to save the details of news and announcements
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void DeleteNewsAnnouncements(int _intNewsAnnouncementsId)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {

                var _varDup = _db.NewsandAnnouncements.Where(x => x.intNewsAnnouncementsId.Equals(_intNewsAnnouncementsId)
                                   ).SingleOrDefault();
                if (_varDup != null)
                {
                    _varDup.chrIsDelelte = 'Y';
                    _varDup.dtDeletedOn = DateTime.Now;
                    _db.SubmitChanges();

                    _varDup = null;
                }
            }
        }
        /// Function Header*******************************************************
        /// Function Name: InesrtSectionVisitedDetails
        /// Function Type: Function
        /// Functionality: used to insert the section visited details
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void InesrtSectionVisitedDetails(Entity.UserInfo oUserInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {

                bool blnIsExists = false;
                var _varSectionVisited = (from _sv in _db.SectionVisiteds
                                          orderby _sv.dtCreatedOn descending
                                          select _sv
                                              ).ToList().Take(1);
                if (_varSectionVisited != null)
                {
                    if (_varSectionVisited.ElementAt(0).strSectionVisited.ToLower().Equals(oUserInfo.StrSectionVisited.ToLower())
                        &&
                        _varSectionVisited.ElementAt(0).strUserId.ToLower().Equals(oUserInfo.StrUserId.ToLower()))
                    {
                        blnIsExists = true;
                    }
                }


                if (!blnIsExists)
                {
                    DAL.SectionVisited oSectionVisited = new SectionVisited();
                    oSectionVisited.strUserId = oUserInfo.StrUserId;
                    oSectionVisited.strUserType = oUserInfo.StrUserType;
                    oSectionVisited.dtCreatedOn = oUserInfo.DtCreatedOn;
                    oSectionVisited.strAgent = oUserInfo.StrAgent;
                    oSectionVisited.strVisitedIP = oUserInfo.StrVisitedIP;
                    oSectionVisited.strSectionVisited = oUserInfo.StrSectionVisited;
                    _db.SectionVisiteds.InsertOnSubmit(oSectionVisited);
                    _db.SubmitChanges();
                    oSectionVisited = null;
                }
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateCompanyDetails
        /// Function Type: Function
        /// Functionality: used to Update the details of company
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        /// 04/09/12 David K. Bowers fixed a bug where address change was not getting stored in db
        /// 04/10/12 David K Bowers added in zip code
        public int UpdateCompanyDetails(Entity.CompanyInfo oCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;
                if (intRetVal.Equals(0))
                {
                    DAL.CompanyInfo oCompanyInfoDAL = _db.CompanyInfos.Where(x => x.intCompanyId.Equals(oCompanyInfo.IntCompanyId)).FirstOrDefault();

                    oCompanyInfoDAL.strCompanyName = oCompanyInfo.StrCompanyName;
                    oCompanyInfoDAL.strCompanyPhone = oCompanyInfo.StrCompanyPhone;
                    oCompanyInfoDAL.strCompanyFax = oCompanyInfo.StrCompanyFax;
                    oCompanyInfoDAL.intCountryId = oCompanyInfo.IntCountryId;
                    oCompanyInfoDAL.intStateId = oCompanyInfo.IntStateId;
                    oCompanyInfoDAL.strStateText = oCompanyInfo.StrStateName;
                    oCompanyInfoDAL.strZipCode = oCompanyInfo.StrZipCode;
                    oCompanyInfoDAL.strCity = oCompanyInfo.StrCity;
                    //04/09/12 David K. Bowers fixed a bug where address change was not getting stored in db
                    oCompanyInfoDAL.strCompanyAddress = oCompanyInfo.StrCompanyAddress;
                    oCompanyInfoDAL.chrIsActive = oCompanyInfo.ChrIsActive;
                    oCompanyInfoDAL.dtModifiedDate = oCompanyInfo.DtModifiedDate;
                    oCompanyInfoDAL.chrIsApproved = oCompanyInfo.ChrIsApproved;
                    _db.SubmitChanges();
                    intRetVal = oCompanyInfoDAL.intCompanyId;
                    oCompanyInfoDAL = null;
                    oCompanyInfo = null;
                }

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateCompanyDetails
        /// Function Type: Function
        /// Functionality: used to Update the details of company
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void UpdateCompanyActiveStatus(int intCompanyId, DateTime dtModifiedDate)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {

                var _varCompInfo = _db.CompanyInfos.Where(x => x.intCompanyId.Equals(intCompanyId)).FirstOrDefault();
                if (_varCompInfo != null)
                {
                    _varCompInfo.chrIsActive = _varCompInfo.chrIsActive.Equals('Y') ? 'N' : 'Y';
                    _varCompInfo.dtModifiedDate = dtModifiedDate;

                    var varAspMembeShip = _db.aspnet_Memberships.Where(x => x.UserId.Equals(_varCompInfo.strUserID)).FirstOrDefault();
                    varAspMembeShip.IsApproved = _varCompInfo.chrIsActive.Equals('Y') ? true : false;

                    _db.SubmitChanges();
                }

            }
        }
 /// Function Header*******************************************************
 /// Function Name: UpdateCompanyApprovedStatus
 /// Function Type: Function
 /// Functionality: used to disapproved the company
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void UpdateCompanyApprovedStatus(List<Entity.CompanyInfo> objListCompanyInfo)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         foreach (var item in objListCompanyInfo)
         {
             var _varCompInfo = _db.CompanyInfos.Where(x => x.intCompanyId.Equals(item.IntCompanyId)).FirstOrDefault();
             if (_varCompInfo != null)
             {
                 _varCompInfo.chrIsApproved = item.ChrIsApproved;
                 _db.SubmitChanges();
             }
         }
     }
 }
        /// Function Header*******************************************************
        /// Function Name: SaveQuestionToHealthCoachFromUser
        /// Function Type: Function
        /// Functionality: used to save the question from user
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveQuestionToHealthCoachFromUser(Entity.CompanyInfo oCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;

                DAL.QuestionsForHealthCoach oQuestionsForHealthCoach = new QuestionsForHealthCoach();
                oQuestionsForHealthCoach.strUserName = oCompanyInfo.StrUserName;
                oQuestionsForHealthCoach.strCategoryName = oCompanyInfo.StrCategoryName;
                oQuestionsForHealthCoach.strCategoryLevel = oCompanyInfo.StrCategoryLevel;
                oQuestionsForHealthCoach.strQuestion = oCompanyInfo.StrQuestion;
                oQuestionsForHealthCoach.strSubject = oCompanyInfo.StrSubject;
                oQuestionsForHealthCoach.strComments = oCompanyInfo.StrComments;
                oQuestionsForHealthCoach.strQuestionType = oCompanyInfo.StrQuestionType;

                oQuestionsForHealthCoach.dtCreatedOn = oCompanyInfo.DtCreatedOn;
                oQuestionsForHealthCoach.chrIsAnsweredGiven = oCompanyInfo.ChrIsAnsweredGiven;
                oQuestionsForHealthCoach.chrIsDeleted = oCompanyInfo.ChrIsDeleted;
                _db.QuestionsForHealthCoaches.InsertOnSubmit(oQuestionsForHealthCoach);

                _db.SubmitChanges();

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveRequestCompanyForUserRegistration
        /// Function Type: Function
        /// Functionality: used to save the details of users who are requested by company
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveRequestCompanyForUserRegistration(List<Entity.CompanyInfo> oListCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;
                foreach (var oCompanyInfo in oListCompanyInfo)
                {
                    intRetVal = 0;
                    var _varUserDuplicate = _db.aspnet_Users.Where(x => x.LoweredUserName.Equals(oCompanyInfo.StrEmpEmail.ToLower())).SingleOrDefault();
                    if (_varUserDuplicate != null)
                    {
                        intRetVal = -1;
                        _varUserDuplicate = null;
                    }
                    else
                    {
                        var _varCompDuplicate = _db.CompanyInfos.Where(x => x.strCompanyEmail.ToLower().Equals(oCompanyInfo.StrEmpEmail.ToLower())).SingleOrDefault();
                        if (_varCompDuplicate != null)
                        {
                            intRetVal = -1;
                            _varCompDuplicate = null;
                        }
                        else
                        {
                            var _varRequestUserDuplicate = _db.CompanyRequestedUsersLists.Where(x => x.strEmpEmail.ToLower().Equals(oCompanyInfo.StrEmpEmail.ToLower())).SingleOrDefault();
                            if (_varRequestUserDuplicate != null)
                            {
                                intRetVal = -1;
                                _varRequestUserDuplicate = null;
                            }
                        }
                    }

                    if (intRetVal.Equals(0))
                    {

                        DAL.CompanyRequestedUsersList oCompanyRequestedUsersListDAL = new CompanyRequestedUsersList();
                        oCompanyRequestedUsersListDAL.intCompanyId = oCompanyInfo.IntCompanyId;
                        oCompanyRequestedUsersListDAL.strEmpCode = oCompanyInfo.StrEmpCode;
                        oCompanyRequestedUsersListDAL.strEmpFirstName = oCompanyInfo.StrEmpFirstName;
                        oCompanyRequestedUsersListDAL.strEmpMiddleName = oCompanyInfo.StrEmpMiddleName;
                        oCompanyRequestedUsersListDAL.strEmpLastName = oCompanyInfo.StrEmpLastName;
                        oCompanyRequestedUsersListDAL.strEmployeeAddress = oCompanyInfo.StrEmployeeAddress;
                        //oCompanyRequestedUsersListDAL.dtEmpDateofBirth = oCompanyInfo.DtEmpDateofBirth;
                        oCompanyRequestedUsersListDAL.dtEmpDateofBirth = System.DateTime.Now;
                        oCompanyRequestedUsersListDAL.strEmpEmail = oCompanyInfo.StrEmpEmail;
                        oCompanyRequestedUsersListDAL.strEmpRelationShipCode = oCompanyInfo.StrEmpRelationShipCode;
                        oCompanyRequestedUsersListDAL.strEmpFamilyStatus = oCompanyInfo.StrEmpFamilyStatus;
                        oCompanyRequestedUsersListDAL.strEmpGender = oCompanyInfo.StrEmpGender;
                        oCompanyRequestedUsersListDAL.strEmpPhoneORCell = oCompanyInfo.StrEmpPhoneORCell;

                        oCompanyRequestedUsersListDAL.chrStatus = oCompanyInfo.ChrStatus;
                        oCompanyRequestedUsersListDAL.dtCreatedDate = oCompanyInfo.DtCreatedDate;
                        _db.CompanyRequestedUsersLists.InsertOnSubmit(oCompanyRequestedUsersListDAL);
                        _db.SubmitChanges();
                        intRetVal = oCompanyRequestedUsersListDAL.intCompanyRequestedUsersListId;
                        oCompanyRequestedUsersListDAL = null;
                    }
                }

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveNewsletter
        /// Function Type: Function
        /// Functionality: used to save the details of newsletters
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int UpdateNewsletter(Entity.NewsInfo oNewsInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;
                var _varDup = _db.Newsletters.Where(x => x.strTitle.ToLower().Equals(oNewsInfo.StrTitle.ToLower())
                                       && x.chrIsDeleted.Equals('N')
                                       && !x.intNewsLetterId.Equals(oNewsInfo.IntNewsLetterId)
                                   ).SingleOrDefault();
                if (_varDup != null)
                {
                    intRetVal = -1;
                    oNewsInfo = null;
                    _varDup = null;
                }
                else
                {
                    _varDup = _db.Newsletters.Where(x => x.intNewsLetterId.Equals(oNewsInfo.IntNewsLetterId)
                                    ).SingleOrDefault();

                    _varDup.strTitle = oNewsInfo.StrTitle;

                    _varDup.chrIsActive = oNewsInfo.ChrIsActive;
                    if (!oNewsInfo.StrNewsletterDate.ToString().Equals("1/1/1999 12:00:00 AM"))
                        _varDup.strNewsletterDate = oNewsInfo.StrNewsletterDate;

                    _varDup.dtModifiedOn = oNewsInfo.DtCreatedOn;
                    _varDup.strDescription = oNewsInfo.StrDescription;
                    if (oNewsInfo.StrPDFFilename.Equals(string.Empty))
                        _varDup.strPDFFileName = "na.pdf";
                    else
                        _varDup.strPDFFileName = oNewsInfo.StrPDFFilename;

                    _db.SubmitChanges();
                    intRetVal = _varDup.intNewsLetterId;
                    _varDup = null;
                    oNewsInfo = null;
                }

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveCompanyDetails
        /// Function Type: Function
        /// Functionality: used to save the details of company
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveCompanyDetails(Entity.CompanyInfo oCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;
                /* var _varUserDuplicate = _db.aspnet_Users.Where(x => x.LoweredUserName.Equals(oCompanyInfo.StrCompanyEmail.ToLower())).SingleOrDefault();
                 if (_varUserDuplicate != null)
                 {
                     intRetVal = -1;
                     _varUserDuplicate = null;
                 }
                 else
                 {
                     var _varCompDuplicate = _db.CompanyInfos.Where(x => x.strCompanyEmail.ToLower().Equals(oCompanyInfo.StrCompanyEmail.ToLower())).SingleOrDefault();
                     if (_varCompDuplicate != null)
                     {
                         intRetVal = -1;
                         _varCompDuplicate = null;
                     }
                 }

                 if (intRetVal.Equals(0))
                 {*/
                DAL.CompanyInfo oCompanyInfoDAL = new DAL.CompanyInfo();
                oCompanyInfoDAL.strCompanyEmail = oCompanyInfo.StrCompanyEmail;
                oCompanyInfoDAL.strPassword = oCompanyInfo.StrPassword;
                oCompanyInfoDAL.strCompanyName = oCompanyInfo.StrCompanyName;
                oCompanyInfoDAL.strCompanyPhone = oCompanyInfo.StrCompanyPhone;
                oCompanyInfoDAL.strCompanyFax = oCompanyInfo.StrCompanyFax;
                oCompanyInfoDAL.intCountryId = oCompanyInfo.IntCountryId;
                oCompanyInfoDAL.intStateId = oCompanyInfo.IntStateId;
                oCompanyInfoDAL.strStateText = oCompanyInfo.StrStateName;

                // David K. Bowers 04/10/12 added in zip code
                oCompanyInfoDAL.strZipCode = oCompanyInfo.StrZipCode;
                // David K. Bowers 04/09/12 fixed a bug where company address was not getting stored in DB
                oCompanyInfoDAL.strCompanyAddress = oCompanyInfo.StrCompanyAddress;
                oCompanyInfoDAL.strCity = oCompanyInfo.StrCity;
                oCompanyInfoDAL.chrIsPaid = oCompanyInfo.ChrIsPaid;
                oCompanyInfoDAL.chrIsActive = oCompanyInfo.ChrIsActive;
                oCompanyInfoDAL.dtCreatedDate = oCompanyInfo.DtCreatedDate;
                oCompanyInfoDAL.dtModifiedDate = oCompanyInfo.DtModifiedDate;
                oCompanyInfoDAL.chrIsDeleted = oCompanyInfo.ChrIsDeleted;
                oCompanyInfoDAL.chrCreatedBy = oCompanyInfo.ChrCreatedBy;
                oCompanyInfoDAL.chrIsApproved = oCompanyInfo.ChrIsApproved;
                _db.CompanyInfos.InsertOnSubmit(oCompanyInfoDAL);
                _db.SubmitChanges();
                _db.ms_UpdateUserINRoles(oCompanyInfoDAL.strCompanyEmail);
                intRetVal = oCompanyInfoDAL.intCompanyId;
                oCompanyInfoDAL = null;
                /* }*/

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveUserRiskStratificationProcessDetails
        /// Function Type: Function
        /// Functionality: used to save the details of risk stratification process step 1 part A
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveUserRiskStratificationProcessDetailsStepSecond(List<Entity.QuestionnaireInfo> oListQuestionnaireInfo, Guid _guidUserId)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;

                var _varQuestion = _db.UserRiskStratificationDetails.Where(x => x.guidUserId.Equals(_guidUserId)
                                                                    && x.strStratificationStep.Equals("2")
                                                                        ).ToList();
                if (_varQuestion != null)
                {
                    _db.UserRiskStratificationDetails.DeleteAllOnSubmit(_varQuestion);
                    _db.SubmitChanges();
                }

                List<DAL.UserRiskStratificationDetail> oListUserRiskStratificationDetailDAL = new List<DAL.UserRiskStratificationDetail>();

                foreach (var item in oListQuestionnaireInfo)
                {
                    DAL.UserRiskStratificationDetail oUserRiskStratificationDetail = new UserRiskStratificationDetail();
                    oUserRiskStratificationDetail.intQuestionnaireId = item.IntQuestionnaireId;
                    oUserRiskStratificationDetail.strQuestion = item.StrQuestion;
                    oUserRiskStratificationDetail.strAnswer = item.StrAnswer;
                    oUserRiskStratificationDetail.dtCreatedOn = item.DtCreatedDate;
                    oUserRiskStratificationDetail.guidUserId = _guidUserId;
                    oUserRiskStratificationDetail.strStratificationStep = "2";
                    oListUserRiskStratificationDetailDAL.Add(oUserRiskStratificationDetail);
                    oUserRiskStratificationDetail = null;
                }

                _db.UserRiskStratificationDetails.InsertAllOnSubmit(oListUserRiskStratificationDetailDAL);
                _db.SubmitChanges();
                UserLib oUserLib = new UserLib();
                oUserLib.UpdateUserStratificationStep(_guidUserId, "2");
                oUserLib = null;

                oListUserRiskStratificationDetailDAL = null;
                oListQuestionnaireInfo = null;
                return intRetVal;
            }
        }
 /// Function Header*******************************************************
 /// Function Name: SaveNewsletter
 /// Function Type: Function
 /// Functionality: used to save the details of newsletters
 /// Input: 
 /// Output: 
 /// Return Value:
 /// Note: 
 /// *********************************************************************
 public void UpdateNewsletterStatus(int _intNewsLetterId)
 {
     using (TLWDALDataContext _db = new TLWDALDataContext())
     {
         var _varDup = _db.Newsletters.Where(x => x.intNewsLetterId.Equals(_intNewsLetterId)
                            ).FirstOrDefault();
         if (_varDup != null)
         {
             _varDup.chrIsActive = _varDup.chrIsActive.Equals('Y') ? 'N' : 'Y';
             _varDup.dtModifiedOn = DateTime.Now;
             _db.SubmitChanges();
             _varDup = null;
         }
     }
 }
        /// Function Header*******************************************************
        /// Function Name: UpdateCompanyApprovedStatus
        /// Function Type: Function
        /// Functionality: used to disapproved the company
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public void UpdateRequestUserStatus(List<Entity.CompanyInfo> objListCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                foreach (var item in objListCompanyInfo)
                {
                    var _varCompInfo = _db.CompanyRequestedUsersLists.Where(x => x.intCompanyRequestedUsersListId.Equals(item.IntCompanyRequestedUsersListId)).FirstOrDefault();
                    if (_varCompInfo != null)
                    {
                        _varCompInfo.chrStatus = item.ChrStatus;
                        _varCompInfo.dtModifiedDate = item.DtModifiedDate;

                        _db.SubmitChanges();
                    }
                }
            }
        }
        public bool UpdateFAQTopicDetails(Entity.FAQTopicInfo oFAQTopicInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                bool _blnRetVal = true;
                var _varFAQTopic = (from _ft in _db.FaqTopics
                                    where _ft.chrIsDeleted.Equals('N')
                                    && _ft.strFaqTopic.ToLower().Equals(oFAQTopicInfo.StrFaqTopic)
                                    && _ft.int_FAQTopicId != oFAQTopicInfo.Int_FAQTopicId
                                    select _ft
                                          ).ToList();
                if (_varFAQTopic.Count > 0)
                    _blnRetVal = false;
                else
                {
                    var oFaqTopic = _db.FaqTopics.Where(x => x.int_FAQTopicId.Equals(oFAQTopicInfo.Int_FAQTopicId)).FirstOrDefault();
                    oFaqTopic.strFaqTopic = oFAQTopicInfo.StrFaqTopic;
                    _db.SubmitChanges();
                    oFaqTopic = null;
                }

                _varFAQTopic = null;
                return _blnRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveFAQTopicDetails
        /// Function Type: Function
        /// Functionality: used to save the details of FAQ topics
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public bool SaveFAQTopicDetails(Entity.FAQTopicInfo oFAQTopicInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                bool _blnRetVal = true;
                var _varFAQTopic = (from _ft in _db.FaqTopics
                                    where _ft.chrIsDeleted.Equals('N')
                                    && _ft.strFaqTopic.ToLower().Equals(oFAQTopicInfo.StrFaqTopic)
                                    select _ft
                                          ).ToList();
                if (_varFAQTopic.Count > 0)
                    _blnRetVal = false;
                else
                {
                    DAL.FaqTopic oFaqTopic = new FaqTopic();
                    oFaqTopic.strFaqTopic = oFAQTopicInfo.StrFaqTopic;
                    oFaqTopic.dtCreatedOn = DateTime.Now;
                    oFaqTopic.strCreatedBy = oFAQTopicInfo.StrCreatedBy;
                    oFaqTopic.chrIsDeleted = 'N';
                    _db.FaqTopics.InsertOnSubmit(oFaqTopic);
                    _db.SubmitChanges();
                    oFaqTopic = null;
                }

                _varFAQTopic = null;
                return _blnRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateQuestionnaireDetails
        /// Function Type: Function
        /// Functionality: used to update the details 
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int UpdateQuestionnaireDetails(Entity.QuestionnaireInfo oQuestionnaireInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;

                var _varDup = _db.Questionnaires.Where(x => x.strQuestion.ToLower().Equals(oQuestionnaireInfo.StrQuestion.ToLower())
                                     && x.chrIsDeleted.Equals('N')
                                     && x.intQuestionnaireType.Equals(oQuestionnaireInfo.IntQuestionnaireType)
                                     && !x.intQuestionnaireId.Equals(oQuestionnaireInfo.IntQuestionnaireId)
                                 ).SingleOrDefault();

                if (_varDup != null)
                {
                    return -1;
                }

                var oQuestionnaireDAL = _db.Questionnaires.Where(x => x.intQuestionnaireId.Equals(oQuestionnaireInfo.IntQuestionnaireId)
                                   ).SingleOrDefault();
                if (oQuestionnaireDAL != null)
                {
                    oQuestionnaireDAL.intQuestionnaireType = oQuestionnaireInfo.IntQuestionnaireType;
                    oQuestionnaireDAL.strQuestion = oQuestionnaireInfo.StrQuestion;
                    oQuestionnaireDAL.chrDisplayYes = oQuestionnaireInfo.ChrDisplayYes;
                    oQuestionnaireDAL.chrDisplayNo = oQuestionnaireInfo.ChrDisplayNo;
                    oQuestionnaireDAL.chrDisplayDontKnow = oQuestionnaireInfo.ChrDisplayDontKnow;
                    oQuestionnaireDAL.chrIsActive = oQuestionnaireInfo.ChrIsActive;
                    oQuestionnaireDAL.dtModifiedDate = oQuestionnaireInfo.DtCreatedDate;
                    oQuestionnaireDAL.strQuestionHeading = oQuestionnaireInfo.StrQuestionHeading;

                    _db.SubmitChanges();

                    intRetVal = oQuestionnaireDAL.intQuestionnaireId;
                    oQuestionnaireDAL = null;
                    oQuestionnaireInfo = null;
                }

                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateGlobalCodesByGlobalCodeId
        /// Function Type: Function
        /// Functionality: used to update the global code details 
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public bool UpdateGlobalCodesByGlobalCodeId(string _strValue, int _intGlobalCodeId)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                try
                {
                    var _varGlobalCode = (from _q in _db.GlobalCodes
                                          where _q.chrisActive.Equals('Y')
                                          && _q.intGlobalCodesId.Equals(_intGlobalCodeId)
                                          select _q).SingleOrDefault();

                    _varGlobalCode.strValue = _strValue;
                    _db.SubmitChanges();

                    return true;
                }
                catch { return false; }
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveEventDetails
        /// Function Type: Function
        /// Functionality: used to save the details of event
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveEventDetails(Entity.EventInfo oEventInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;
                DAL.Event oEventDAL = new Event();
                oEventDAL.strUserName = oEventInfo.StrUserName;
                oEventDAL.dtEventDate = oEventInfo.DtEventDate;
                oEventDAL.strActivity = oEventInfo.StrActivity;
                oEventDAL.strLocation = oEventInfo.StrLocation;
                oEventDAL.strComments = oEventInfo.StrComments;
                oEventDAL.chrStatus = oEventInfo.ChrStatus;
                oEventDAL.dtCreatedOn = oEventInfo.DtCreatedOn;
                oEventDAL.chrIsDeleted = oEventInfo.ChrIsDeleted;
                oEventDAL.chrIsActive = oEventInfo.ChrIsActive;
                oEventDAL.dtModifiedOn = oEventInfo.DtCreatedOn;
                _db.Events.InsertOnSubmit(oEventDAL);
                _db.SubmitChanges();

                intRetVal = oEventDAL.intEventsId;
                oEventDAL = null;
                oEventInfo = null;
                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateLibraryDetails
        /// Function Type: Function
        /// Functionality: used to update the details of library
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int UpdateLibraryDetails(Entity.LibraryInfo oLibraryInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;
                DAL.Library oLibraryDAL = _db.Libraries.Where(x => x.intLibraryId.Equals(oLibraryInfo.IntLibraryId)).FirstOrDefault();
                oLibraryDAL.strTitle = oLibraryInfo.StrTitle;
                oLibraryDAL.strDescription = oLibraryInfo.StrDescription;
                oLibraryDAL.strCategory = oLibraryInfo.StrCategory;
                oLibraryDAL.strLocation = oLibraryInfo.StrLocation;
                oLibraryDAL.strLocationType = oLibraryInfo.StrLocationType;
                oLibraryDAL.dtLibraryDate = oLibraryInfo.DtLibraryDate;
                oLibraryDAL.dtCreatedDate = oLibraryInfo.DtCreatedDate;
                oLibraryDAL.chrIsActive = oLibraryInfo.ChrIsActive;
                oLibraryDAL.chrIsDeleted = oLibraryInfo.ChrIsDeleted;
                oLibraryDAL.dtDeletedDate = oLibraryInfo.DtDeletedDate;
                oLibraryDAL.dtModifiedDate = oLibraryInfo.DtModifiedDate;
                _db.SubmitChanges();

                intRetVal = oLibraryDAL.intLibraryId;

                oLibraryDAL = null;
                oLibraryInfo = null;
                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateEventDetails
        /// Function Type: Function
        /// Functionality: used to update the details of event
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int UpdateEventDetails(Entity.EventInfo oEventInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;
                DAL.Event oEventDAL = _db.Events.Where(x => x.intEventsId.Equals(oEventInfo.IntEventsId)).FirstOrDefault();
                oEventDAL.dtEventDate = oEventInfo.DtEventDate;
                oEventDAL.strActivity = oEventInfo.StrActivity;
                oEventDAL.strLocation = oEventInfo.StrLocation;
                oEventDAL.strComments = oEventInfo.StrComments;
                oEventDAL.chrStatus = oEventInfo.ChrStatus;
                oEventDAL.dtModifiedOn = oEventInfo.DtCreatedOn;
                oEventDAL.chrIsActive = oEventInfo.ChrIsActive;
                _db.SubmitChanges();

                intRetVal = oEventDAL.intEventsId;
                oEventDAL = null;
                oEventInfo = null;
                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: PrivateAnsweredtoUsersQuestion
        /// Function Type: Function
        /// Functionality: used to save the answered to private question
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveAnswerFromHealthCoach(Entity.CompanyInfo oCompanyInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;

                DAL.UsersPrivateAnswer oUsersPrivateAnswer = new UsersPrivateAnswer();

                oUsersPrivateAnswer.intQuestionId = oCompanyInfo.IntQuestionId;
                oUsersPrivateAnswer.strAnswer = oCompanyInfo.StrAnswer;
                oUsersPrivateAnswer.dtAnsweredOn = oCompanyInfo.DtAnsweredOn;
                oUsersPrivateAnswer.strAnswerBy = oCompanyInfo.StrAnsweredBy;

                _db.UsersPrivateAnswers.InsertOnSubmit(oUsersPrivateAnswer);

                if (oCompanyInfo.StrQuestionType.ToLower().Equals("public"))
                {
                    var _varFAQ = (from _f in _db.FAQs
                                   where _f.intQuestionId.Equals(oCompanyInfo.IntQuestionId)
                                   select _f).FirstOrDefault();
                    if (_varFAQ != null)
                    {
                        _varFAQ.strAnswer = oCompanyInfo.StrAnswer;
                    }
                    else
                    {
                        DAL.FAQ oFAQ = new FAQ();
                        oFAQ.intQuestionId = oCompanyInfo.IntQuestionId;
                        oFAQ.strHeading = "Users FAQ";
                        oFAQ.strQuestion = oCompanyInfo.StrQuestion;
                        oFAQ.strAnswer = oCompanyInfo.StrAnswer;
                        oFAQ.chrUserType = 'U';
                        oFAQ.dtCreatedOn = oCompanyInfo.DtAnsweredOn;
                        oFAQ.strUserId = oCompanyInfo.StrUserId;
                        oFAQ.chrisDeleted = 'N';
                        _db.FAQs.InsertOnSubmit(oFAQ);
                    }

                }

                var _varQuestion = _db.QuestionsForHealthCoaches.Where(x => x.intQuestionId.Equals(oCompanyInfo.IntQuestionId)).FirstOrDefault();
                if (_varQuestion != null)
                {
                    _varQuestion.strQuestionType = oCompanyInfo.StrQuestionType;
                    _varQuestion.chrIsAnsweredGiven = 'Y';
                    //  _db.SubmitChanges();
                }

                _db.SubmitChanges();
                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: SaveLibraryDetails
        /// Function Type: Function
        /// Functionality: used to save the details of library
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int SaveLibraryDetails(Entity.LibraryInfo oLibraryInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 0;

                var _varChkDuplicate = _db.Libraries.Where(x => x.strTitle.ToLower().Equals(oLibraryInfo.StrTitle.ToLower())
                                                                                                                    )

                    .FirstOrDefault();
                bool blnIsLibraryExists = false;
                if (_varChkDuplicate != null)
                {
                    string strOldDate = _varChkDuplicate.dtCreatedDate.ToShortDateString();
                    if (strOldDate.Equals(oLibraryInfo.DtCreatedDate.ToShortDateString()))
                    {
                        blnIsLibraryExists = true;
                    }
                }

                if (!blnIsLibraryExists)
                {
                    DAL.Library oLibraryDAL = new Library();

                    oLibraryDAL.strTitle = oLibraryInfo.StrTitle;
                    oLibraryDAL.strDescription = oLibraryInfo.StrDescription;
                    oLibraryDAL.strCategory = oLibraryInfo.StrCategory;
                    oLibraryDAL.strLocation = oLibraryInfo.StrLocation;
                    oLibraryDAL.strLocationType = oLibraryInfo.StrLocationType;
                    oLibraryDAL.dtLibraryDate = oLibraryInfo.DtLibraryDate;
                    oLibraryDAL.dtCreatedDate = oLibraryInfo.DtCreatedDate;
                    oLibraryDAL.chrIsActive = oLibraryInfo.ChrIsActive;
                    oLibraryDAL.chrIsDeleted = oLibraryInfo.ChrIsDeleted;
                    oLibraryDAL.dtDeletedDate = oLibraryInfo.DtDeletedDate;
                    oLibraryDAL.dtModifiedDate = oLibraryInfo.DtModifiedDate;
                    _db.Libraries.InsertOnSubmit(oLibraryDAL);
                    _db.SubmitChanges();

                    intRetVal = oLibraryDAL.intLibraryId;
                    oLibraryDAL = null;
                }

                oLibraryInfo = null;
                return intRetVal;
            }
        }
        /// Function Header*******************************************************
        /// Function Name: UpdateNewsAnnouncements
        /// Function Type: Function
        /// Functionality: used to save the details of news and announcements
        /// Input: 
        /// Output: 
        /// Return Value:
        /// Note: 
        /// *********************************************************************
        public int UpdateNewsAnnouncements(Entity.NewsInfo oNewsInfo)
        {
            using (TLWDALDataContext _db = new TLWDALDataContext())
            {
                int intRetVal = 1;
                var _varDup = _db.NewsandAnnouncements.Where(x => x.strHeading.ToLower().Equals(oNewsInfo.StrHeading.ToLower())
                                       && x.chrIsDelelte.Equals('N')
                                       && !x.intNewsAnnouncementsId.Equals(oNewsInfo.IntNewsAnnouncementsId)
                                   ).SingleOrDefault();
                if (_varDup != null)
                {
                    intRetVal = -1;
                    oNewsInfo = null;
                    _varDup = null;
                }
                else
                {
                    _varDup = _db.NewsandAnnouncements.Where(x => x.intNewsAnnouncementsId.Equals(oNewsInfo.IntNewsAnnouncementsId)
                                                           ).FirstOrDefault();
                    if (_varDup != null)
                    {
                        _varDup.strHeading = oNewsInfo.StrHeading;
                        _varDup.chrIsActive = oNewsInfo.ChrIsActive;
                        _varDup.chrIsHomePage = oNewsInfo.ChrIsHomePage;
                        _varDup.dtModifiedOn = oNewsInfo.DtCreatedOn;
                        _varDup.strDescription = oNewsInfo.StrDescription;
                        _varDup.strHeading = oNewsInfo.StrHeading;

                        if (oNewsInfo.StrPDFFilename.Equals(string.Empty))
                            _varDup.strPDFFilename = "na.pdf";
                        else
                            _varDup.strPDFFilename = oNewsInfo.StrPDFFilename;

                        _varDup.strDirectLink = oNewsInfo.StrDirectLink;
                        _db.SubmitChanges();
                    }

                    intRetVal = _varDup.intNewsAnnouncementsId;
                    _varDup = null;
                    oNewsInfo = null;
                }

                return intRetVal;
            }
        }