/// <summary>
        ///
        /// </summary>
        /// <param name="colSettings"></param>
        /// <param name="portalId"></param>
        /// <returns></returns>
        public static List <QaSettingInfo> GetOpThresholdCollection(List <SettingInfo> colSettings, int portalId)
        {
            // determine if operational threshold settings exist for this portal
            var colOpThreshSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.OperationalThresholds select t);
            var colOpThresholds     = new List <QaSettingInfo>();

            switch (colOpThreshSettings.Count())
            {
            case 0:

                //todo Add New default values to database
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostChangeVoteWindowMinutes.ToString(), Constants.DefaultOpPostChangeVoteWindowMinutes));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostFlagCompleteCount.ToString(), Constants.DefaultOpPostFlagCompleteCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostFlagWindowHours.ToString(), Constants.DefaultOpPostFlagWindowHours));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionCloseCompleteVoteCount.ToString(), Constants.DefaultOpQuestionCloseCompleteVoteCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionCloseWindowDays.ToString(), Constants.DefaultOpQuestionCloseWindowDays));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionFlagHomeRemoveCount.ToString(), Constants.DefaultOpQuestionFlagHomeRemoveCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagCloseWindowDays.ToString(), Constants.DefaultOpTagCloseWindowDays));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagFlagCompleteCount.ToString(), Constants.DefaultOpTagFlagCompleteCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagFlagWindowHours.ToString(), Constants.DefaultOpTagFlagWindowHours));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymApproveCount.ToString(), Constants.DefaultOpTermSynonymApproveCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymRejectCount.ToString(), Constants.DefaultOpTermSynonymRejectCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymMaxCount.ToString(), Constants.DefaultOpTermSynonymMaxCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserCloseVoteCount.ToString(), Constants.DefaultOpUserCloseVoteCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserFlagPostModerateCount.ToString(), Constants.DefaultOpUserFlagPostModerateCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserFlagPostSpamCount.ToString(), Constants.DefaultOpUserFlagPostSpamCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserTermSynonymCreateMinAnswerCount.ToString(), Constants.DefaultOpUserTermSynonymCreateMinAnswerCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserTermSynonymVoteMinAnswerScoreCount.ToString(), Constants.DefaultOpUserTermSynonymVoteMinAnswerScoreCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserUpVoteAnswerCount.ToString(), Constants.DefaultOpUserUpVoteAnswerCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserUpVoteQuestionCount.ToString(), Constants.DefaultOpUserUpVoteQuestionCount));
                //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionHomeMinScore.ToString(), Constants.DefaultOpHomeQuestionMinScore));
                break;

            case 19:
                var objNewSetting = new SettingInfo
                {
                    PortalId = portalId,
                    TypeId   = (int)Constants.SettingTypes.OperationalThresholds,
                    Key      = Constants.OpThresholds.QuestionHomeMinScore.ToString(),
                    Value    = Constants.DefaultOpHomeQuestionMinScore.ToString()
                };

                var cntQa = new SettingController();
                cntQa.UpdateSetting(objNewSetting);

                DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.QaSettingsCacheKey + portalId);

                colOpThreshSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.OperationalThresholds select t);
                colOpThresholds.AddRange(colOpThreshSettings.Select(objSetting => BuildOpThreshold(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                break;

            default:
                colOpThresholds.AddRange(colOpThreshSettings.Select(objSetting => BuildOpThreshold(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                break;
            }

            return(colOpThresholds);
        }
 public void UpdateSetting(SettingInfo infoSS)
 {
 }
 public void AddSetting(SettingInfo infoSS)
 {
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="colSettings"></param>
        /// <param name="portalId"></param>
        /// <returns></returns>
        public static List<QaSettingInfo> GetOpThresholdCollection(List<SettingInfo> colSettings, int portalId)
        {
            // determine if operational threshold settings exist for this portal
            var colOpThreshSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.OperationalThresholds select t);
            var colOpThresholds = new List<QaSettingInfo>();

            switch (colOpThreshSettings.Count())
            {
                case 0:

                    //todo Add New default values to database
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostChangeVoteWindowMinutes.ToString(), Constants.DefaultOpPostChangeVoteWindowMinutes));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostFlagCompleteCount.ToString(), Constants.DefaultOpPostFlagCompleteCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.PostFlagWindowHours.ToString(), Constants.DefaultOpPostFlagWindowHours));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionCloseCompleteVoteCount.ToString(), Constants.DefaultOpQuestionCloseCompleteVoteCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionCloseWindowDays.ToString(), Constants.DefaultOpQuestionCloseWindowDays));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionFlagHomeRemoveCount.ToString(), Constants.DefaultOpQuestionFlagHomeRemoveCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagCloseWindowDays.ToString(), Constants.DefaultOpTagCloseWindowDays));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagFlagCompleteCount.ToString(), Constants.DefaultOpTagFlagCompleteCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TagFlagWindowHours.ToString(), Constants.DefaultOpTagFlagWindowHours));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymApproveCount.ToString(), Constants.DefaultOpTermSynonymApproveCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymRejectCount.ToString(), Constants.DefaultOpTermSynonymRejectCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.TermSynonymMaxCount.ToString(), Constants.DefaultOpTermSynonymMaxCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserCloseVoteCount.ToString(), Constants.DefaultOpUserCloseVoteCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserFlagPostModerateCount.ToString(), Constants.DefaultOpUserFlagPostModerateCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserFlagPostSpamCount.ToString(), Constants.DefaultOpUserFlagPostSpamCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserTermSynonymCreateMinAnswerCount.ToString(), Constants.DefaultOpUserTermSynonymCreateMinAnswerCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserTermSynonymVoteMinAnswerScoreCount.ToString(), Constants.DefaultOpUserTermSynonymVoteMinAnswerScoreCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserUpVoteAnswerCount.ToString(), Constants.DefaultOpUserUpVoteAnswerCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.UserUpVoteQuestionCount.ToString(), Constants.DefaultOpUserUpVoteQuestionCount));
                    //colOpThresholds.Add(BuildOpThreshold(Constants.OpThresholds.QuestionHomeMinScore.ToString(), Constants.DefaultOpHomeQuestionMinScore));
                    break;
                case 19:
                    var objNewSetting = new SettingInfo
                    {
                        PortalId = portalId,
                        TypeId = (int)Constants.SettingTypes.OperationalThresholds,
                        Key = Constants.OpThresholds.QuestionHomeMinScore.ToString(),
                        Value = Constants.DefaultOpHomeQuestionMinScore.ToString()
                    };

                    var cntQa = new SettingController();
                    cntQa.UpdateSetting(objNewSetting);

                    DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.QaSettingsCacheKey + portalId);

                    colOpThreshSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.OperationalThresholds select t);
                    colOpThresholds.AddRange(colOpThreshSettings.Select(objSetting => BuildOpThreshold(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                    break;
                default :
                    colOpThresholds.AddRange(colOpThreshSettings.Select(objSetting => BuildOpThreshold(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                    break;
            }

            return colOpThresholds;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="colSettings"></param>
        /// <param name="portalId"></param>
        /// <returns></returns>
        public static List<QaSettingInfo> GetUserScoringCollection(List<SettingInfo> colSettings, int portalId)
        {
            // determine if user scoring action settings exist for this portal
            var colUserScoringSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.UserScoringActionValue select t);
            var x = colUserScoringSettings.Count();

            var colScoringActions = new List<QaSettingInfo>();

            switch (colUserScoringSettings.Count())
            {
                case 0:
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AdminEntered.ToString(), Constants.DefaultScoreAdminEntered)); // static 0
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ApprovedPostEdit.ToString(), Constants.DefaultScoreApprovedPostEdit));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ApprovedTagEdit.ToString(), Constants.DefaultScoreApprovedTagEdit));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedFlaggedQuestion.ToString(), Constants.DefaultScoreAskedFlaggedQuestion));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestion.ToString(), Constants.DefaultScoreAskedQuestion));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestionVotedDown.ToString(), Constants.DefaultScoreAskedQuestionVotedDown));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestionVotedUp.ToString(), Constants.DefaultScoreAskedQuestionVotedUp));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.BountyPaid.ToString(), Constants.DefaultScoreBountyPaid)); // static 0
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.BountyReceived.ToString(), Constants.DefaultScoreBountyReceived)); // static 0
                    //createtag
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.CreatedTagSynonym.ToString(), Constants.DefaultScoreCreatedTagSynonym));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.Commented.ToString(), Constants.DefaultScoreCommented));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedPost.ToString(), Constants.DefaultScoreEditedPost));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTag.ToString(), Constants.DefaultScoreEditedTag));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTagVotedDown.ToString(), Constants.DefaultScoreEditedTagVotedDown));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTagVotedUp.ToString(), Constants.DefaultScoreEditedTagVotedUp));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.FirstLoggedInView.ToString(), Constants.DefaultScoreFirstLoggedInView));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAcceptedAnswer.ToString(), Constants.DefaultScoreProvidedAcceptedAnswer));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswer.ToString(), Constants.DefaultScoreProvidedAnswer));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswerVotedDown.ToString(), Constants.DefaultScoreProvidedAnswerVotedDown));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswerVotedUp.ToString(), Constants.DefaultScoreProvidedAnswerVotedUp));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedFlaggedAnswer.ToString(), Constants.DefaultScoreProvidedFlaggedAnswer));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedDownAnswer.ToString(), Constants.DefaultScoreVotedDownAnswer));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedDownQuestion.ToString(), Constants.DefaultScoreVotedDownQuestion));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedSynonymDown.ToString(), Constants.DefaultScoreVotedSynonymDown));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedSynonymUp.ToString(), Constants.DefaultScoreVotedSynonymUp));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedTagDown.ToString(), Constants.DefaultScoreVotedTagDown));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedTagUp.ToString(), Constants.DefaultScoreVotedTagUp));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedUpAnswer.ToString(), Constants.DefaultScoreVotedUpAnswer));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedUpQuestion.ToString(), Constants.DefaultScoreVotedUpQuestion));
                    colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AcceptedQuestionAnswer.ToString(), Constants.DefaultScoreAcceptedAnswer)); // new
                    break;
                case 29:
                    var objNewSetting = new SettingInfo
                    {
                        PortalId = portalId,
                        TypeId = (int)Constants.SettingTypes.UserScoringActionValue,
                        Key = Constants.UserScoringActions.AcceptedQuestionAnswer.ToString(),
                        Value = Constants.DefaultScoreAcceptedAnswer.ToString()
                    };

                    var cntQa = new SettingController();
                    cntQa.UpdateSetting(objNewSetting);

                    DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.QaSettingsCacheKey + portalId);

                    colUserScoringSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.UserScoringActionValue select t);
                    colScoringActions.AddRange(colUserScoringSettings.Select(objSetting => BuildUserScore(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                    break;
                default:
                    colScoringActions.AddRange(colUserScoringSettings.Select(objSetting => BuildUserScore(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                    break;
            }

            return colScoringActions;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="colSettings"></param>
        /// <param name="portalId"></param>
        /// <returns></returns>
        public static List <QaSettingInfo> GetUserScoringCollection(List <SettingInfo> colSettings, int portalId)
        {
            // determine if user scoring action settings exist for this portal
            var colUserScoringSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.UserScoringActionValue select t);
            var x = colUserScoringSettings.Count();

            var colScoringActions = new List <QaSettingInfo>();

            switch (colUserScoringSettings.Count())
            {
            case 0:
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AdminEntered.ToString(), Constants.DefaultScoreAdminEntered));     // static 0
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ApprovedPostEdit.ToString(), Constants.DefaultScoreApprovedPostEdit));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ApprovedTagEdit.ToString(), Constants.DefaultScoreApprovedTagEdit));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedFlaggedQuestion.ToString(), Constants.DefaultScoreAskedFlaggedQuestion));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestion.ToString(), Constants.DefaultScoreAskedQuestion));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestionVotedDown.ToString(), Constants.DefaultScoreAskedQuestionVotedDown));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AskedQuestionVotedUp.ToString(), Constants.DefaultScoreAskedQuestionVotedUp));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.BountyPaid.ToString(), Constants.DefaultScoreBountyPaid));         // static 0
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.BountyReceived.ToString(), Constants.DefaultScoreBountyReceived)); // static 0
                //createtag
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.CreatedTagSynonym.ToString(), Constants.DefaultScoreCreatedTagSynonym));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.Commented.ToString(), Constants.DefaultScoreCommented));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedPost.ToString(), Constants.DefaultScoreEditedPost));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTag.ToString(), Constants.DefaultScoreEditedTag));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTagVotedDown.ToString(), Constants.DefaultScoreEditedTagVotedDown));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.EditedTagVotedUp.ToString(), Constants.DefaultScoreEditedTagVotedUp));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.FirstLoggedInView.ToString(), Constants.DefaultScoreFirstLoggedInView));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAcceptedAnswer.ToString(), Constants.DefaultScoreProvidedAcceptedAnswer));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswer.ToString(), Constants.DefaultScoreProvidedAnswer));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswerVotedDown.ToString(), Constants.DefaultScoreProvidedAnswerVotedDown));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedAnswerVotedUp.ToString(), Constants.DefaultScoreProvidedAnswerVotedUp));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.ProvidedFlaggedAnswer.ToString(), Constants.DefaultScoreProvidedFlaggedAnswer));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedDownAnswer.ToString(), Constants.DefaultScoreVotedDownAnswer));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedDownQuestion.ToString(), Constants.DefaultScoreVotedDownQuestion));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedSynonymDown.ToString(), Constants.DefaultScoreVotedSynonymDown));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedSynonymUp.ToString(), Constants.DefaultScoreVotedSynonymUp));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedTagDown.ToString(), Constants.DefaultScoreVotedTagDown));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedTagUp.ToString(), Constants.DefaultScoreVotedTagUp));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedUpAnswer.ToString(), Constants.DefaultScoreVotedUpAnswer));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.VotedUpQuestion.ToString(), Constants.DefaultScoreVotedUpQuestion));
                colScoringActions.Add(BuildUserScore(Constants.UserScoringActions.AcceptedQuestionAnswer.ToString(), Constants.DefaultScoreAcceptedAnswer));     // new
                break;

            case 29:
                var objNewSetting = new SettingInfo
                {
                    PortalId = portalId,
                    TypeId   = (int)Constants.SettingTypes.UserScoringActionValue,
                    Key      = Constants.UserScoringActions.AcceptedQuestionAnswer.ToString(),
                    Value    = Constants.DefaultScoreAcceptedAnswer.ToString()
                };

                var cntQa = new SettingController();
                cntQa.UpdateSetting(objNewSetting);

                DataCache.RemoveCache(Constants.ModuleCacheKey + Constants.QaSettingsCacheKey + portalId);

                colUserScoringSettings = (from t in colSettings where t.TypeId == (int)Constants.SettingTypes.UserScoringActionValue select t);
                colScoringActions.AddRange(colUserScoringSettings.Select(objSetting => BuildUserScore(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                break;

            default:
                colScoringActions.AddRange(colUserScoringSettings.Select(objSetting => BuildUserScore(objSetting.Key, Convert.ToInt32(objSetting.Value))));
                break;
            }

            return(colScoringActions);
        }