Ejemplo n.º 1
0
    public static Questions GetNextQuestion(int currentQuestionID)
    {
        IList<Questions> questions = CurrentQuestionList;
        string Keyword = CurrentQuestionSearchCriteriaForKeyword;
        string Category = CurrentQuestionSearchCriteriaForCategory;

        Questions nextQuestion = null;

        if (questions != null)
        {
            for (int i = 0; i < questions.Count; i++)
            {
                if (questions[i].QuestionID == currentQuestionID && i + 1 < questions.Count)
                {
                    nextQuestion = questions[i + 1];
                }
            }
        }

        if (nextQuestion == null)
        {
            //Reload the questions based upon the current criteria
            int pageSize = ConfigReader.AdminQuestionListSize;
            App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
            int pageNo = CurrentQuestionPageNo + 1;
            CurrentQuestionPageNo = pageNo;

            if (string.IsNullOrEmpty(Keyword) && string.IsNullOrEmpty(Category))
            {
                questions = manager.GetPagedList(pageNo, 1000000).ToList();
            }
            else
            {
                bool filter = false;
                if (SessionCache.CurrentUser != null)
                {
                    if (SessionCache.CurrentUser.Mode == "Filtered")
                    {
                        filter = true;
                    }
                }
                questions = manager.GetPagedListByKeywordOrCategory(pageNo, 10000000, Keyword, Category, SessionCache.CurrentUser.Author_ID, filter).ToList();
            }

            CurrentQuestionList = questions;

            if (questions != null)
            {
                for (int i = 0; i < questions.Count; i++)
                {
                    if (questions[i].QuestionID == currentQuestionID && i + 1 < questions.Count)
                    {
                        nextQuestion = questions[i + 1];
                    }
                }
            }
        }

        return nextQuestion;
    }
Ejemplo n.º 2
0
    //private void ValidateFaceBookUser()
    //{
    //    FBConnectAuth.FBConnectAuthentication auth = new FBConnectAuth.FBConnectAuthentication(ConfigReader.FaceBookAPIKey, ConfigReader.FaceBookSecretPhrase);
    //    if (auth.Validate() != FBConnectAuth.ValidationState.Valid)
    //    {
    //        // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.
    //    }
    //    else
    //    {
    //        FBConnectAuth.FBConnectSession faceBookSession = auth.GetSession();
    //        String userId = faceBookSession.UserID;
    //        String sessionKey = faceBookSession.SessionKey;
    //    }
    //}
    private void SetInitialValues()
    {
        App.Domain.Questions.QuestionsManager manager = new App.Domain.Questions.QuestionsManager();
        _NumberOfQuestions = manager.GetPagedList(1, int.MaxValue).Count;
        _LastQuestionDate = manager.LastQuestionDate().ToString(AppConstants.ValueOf.DATE_FROMAT_DISPLAY_WITH_TIME);

        _QuestionOfTheWeek = manager.Get(ConfigReader.QuestionOfTheWeekID);
        if (_QuestionOfTheWeek != null)
        {
            ViewState[QUESTION_OF_THE_WEEK_USERID] = 2;
            ViewState[CORRECT_ANSWER] = _QuestionOfTheWeek.CorrectAnswer;
        }
    }