コード例 #1
0
    /// <summary>
    /// Check if there is an existing Student's Google account
    /// </summary>
    /// <param name="googleId"></param>
    /// <returns>Return true if Student's Google account exists</returns>
    public bool CheckGoogleExist(string googleId)
    {
        string             query   = "SELECT COUNT(1) FROM Student WHERE GoogleAccountId = @GoogleAccountId";
        BaseDaoImpl <bool> baseDao = new BaseDaoImpl <bool>();
        var  studentObj            = new { GoogleAccountId = googleId };
        bool exist = baseDao.ExecuteScalar(query, studentObj);

        return(exist);
    }
コード例 #2
0
    /// <summary>
    /// Check if Student who has logged in with Facebook account has an existing Chrracter
    /// </summary>
    /// <param name="fbId"></param>
    /// <returns>Return true if Student has existing Character</returns>
    public bool CheckFacebookCharExist(string fbId)
    {
        string             query   = "SELECT COUNT(1) FROM Student WHERE FacebookAccountId = @FacebookAccountId AND CharId != ''";
        BaseDaoImpl <bool> baseDao = new BaseDaoImpl <bool>();
        var  studentObj            = new { FacebookAccountId = fbId };
        bool exist = baseDao.ExecuteScalar(query, studentObj);

        return(exist);
    }
コード例 #3
0
    /// <summary>
    /// Get Student's campaign rank
    /// </summary>
    /// <param name="studentId"></param>
    /// <returns>Return integer result of Student's campaign rank</returns>
    public int GetCampaignRanking(int studentId)
    {
        BaseDaoImpl <int> baseDao = new BaseDaoImpl <int>();
        string            query   = "SELECT (COUNT(0)+1) AS StudentRank FROM StudentLevelTotalScore s1, StudentLevelTotalScore s2 " +
                                    "WHERE s1.StudentId = @StudentId AND s2.totalLevelScore > s1.totalLevelScore";
        int result = baseDao.ExecuteScalar(query, new { StudentId = studentId });

        return(result);
    }
コード例 #4
0
    /// <summary>
    /// Check if Student has an existing account
    /// </summary>
    /// <param name="studentId"></param>
    /// <returns>Return true if Student's record exist</returns>
    public bool CheckStudentExist(int studentId)
    {
        string             query   = "SELECT COUNT(1) FROM Student WHERE StudentId = @StudentId";
        BaseDaoImpl <bool> baseDao = new BaseDaoImpl <bool>();
        var  studentObj            = new { StudentId = studentId };
        bool exist = baseDao.ExecuteScalar(query, studentObj);

        return(exist);
    }
コード例 #5
0
    /// <summary>
    /// Check if Student has cleared the selected World's Section
    /// </summary>
    /// <param name="worldId"></param>
    /// <param name="sectionId"></param>
    /// <param name="studentId"></param>
    /// <returns>Return int result 1 if Student has cleared the section</returns>
    public int CheckSectionCleared(int worldId, int sectionId, int studentId)
    {
        string query = String.Format("SELECT LevelId FROM ( SELECT l.LevelId FROM Level l WHERE l.WorldId = {0} AND l.SectionId = {1} UNION ALL " +
                                     "SELECT ss.LevelId FROM StudentScore ss WHERE ss.WorldId = {0} AND ss.SectionId = {1} AND ss.StudentId = {2}) tbl " +
                                     "GROUP BY LevelId HAVING count(*) = 1 ORDER BY LevelId", worldId, sectionId, studentId);
        BaseDaoImpl <int> baseDao = new BaseDaoImpl <int>();
        int result = baseDao.ExecuteScalar(query);

        return(result);
    }