コード例 #1
0
        public List <UserRanking> GetUsersCompanyLeaderboard(long?companyId, Leaderboard.Type type,
                                                             Leaderboard.TimeSpan timeSpan, int page, int limit)
        {
            var con = new SqlConnection(Config.ConnectionString);
            var cmd = new SqlCommand
            {
                CommandText = $"get_users_leaderboard_company_{timeSpan}_{type} {companyId}, {limit}, {page}",
                Connection  = con
            };

            con.Open();

            var ranks = new List <UserRanking>();

            try
            {
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ranks.Add(_userRanksMapper.MapFrom(reader));
                    }
                }
            }
            finally
            {
                con.Close();
            }

            return(ranks);
        }
コード例 #2
0
 public List <CompanyRanking> GetCompaniesLeaderboards(
     Leaderboard.Type type,
     Leaderboard.TimeSpan timeSpan,
     int page,
     int limit)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
 public Rankings GetCompanyRanks(
     long companyId,
     Leaderboard.Type type,
     Leaderboard.TimeSpan timeSpan,
     int page,
     int limit)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
 public Rankings GetUserRanks(
     long userId,
     Leaderboard.Type type,
     Leaderboard.Range range,
     Leaderboard.TimeSpan timeSpan,
     int page,
     int limit)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
        public IHttpActionResult GetUsersLeaderboard(
            [FromUri] Leaderboard.Type type         = Leaderboard.Type.Shares,
            [FromUri] Leaderboard.Range range       = Leaderboard.Range.Global,
            [FromUri] Leaderboard.TimeSpan timeSpan = Leaderboard.TimeSpan.AllTime,
            [FromUri] int?companyId = null,
            [FromUri] int page      = 1,
            [FromUri] int limit     = 20)
        {
            if (!Session.Authorized)
            {
                return(Unauthorized());
            }

            var leaderboard = range == Leaderboard.Range.Company
                ? _leaderboardsRepo.GetUsersCompanyLeaderboard(companyId, type, timeSpan, page, limit)
                : _leaderboardsRepo.GetUsersGlobalLeaderboard(type, timeSpan, page, limit);


            return(Ok(leaderboard));
        }
コード例 #6
0
        public IHttpActionResult GetCompaniesLeaderboard(
            [FromUri] Leaderboard.Type?type         = null,
            [FromUri] Leaderboard.Range range       = Leaderboard.Range.Global,
            [FromUri] Leaderboard.TimeSpan timeSpan = Leaderboard.TimeSpan.AllTime,
            [FromUri] int page  = 1,
            [FromUri] int limit = 20)
        {
            if (!Session.Authorized)
            {
                return(Unauthorized());
            }

            if (type == null)
            {
                return(BadRequest("Campo Type mancante"));
            }

            var data = type + " " + range + " " + timeSpan;

            return(Ok());
        }