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);
        }
 public List <CompanyRanking> GetCompaniesLeaderboards(
     Leaderboard.Type type,
     Leaderboard.TimeSpan timeSpan,
     int page,
     int limit)
 {
     throw new NotImplementedException();
 }
 public Rankings GetCompanyRanks(
     long companyId,
     Leaderboard.Type type,
     Leaderboard.TimeSpan timeSpan,
     int page,
     int limit)
 {
     throw new NotImplementedException();
 }
 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());
        }