Q:

Razor Page Ranking

I am trying to make a ranking page using razor page.
I will be getting my data from API (which was linked to the db).
The sample data in the DB is
CREATE TABLE Member (Id int, Points int);
INSERT INTO Member VALUES (1, 200);
INSERT INTO Member VALUES (2, 100);
INSERT INTO Member VALUES (3, 20);
INSERT INTO Member VALUES (4, 50);
INSERT INTO Member VALUES (5, 300);

I signed in as memberid = 2, so my current ranking is 3.
I need to display out in a table the data of rank 2, 3, and 4. 
Sample display is 
Rank      MemberID           Points
 2            1                200
 3            2                100
 4            4                 50

How to acheive this?
    using (var client = new HttpClient())
            {
                var id = Request.Cookies["MemberId"].ToString();
                client.BaseAddress = new Uri(baseUrl);
                var responseTask = client.GetAsync("api/members");
                responseTask.Wait();
                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var memberResponse = result.Content.ReadAsStringAsync().Result;
                    Member = JsonConvert.DeserializeObject<IList<Member>>(memberResponse);
                    var member = Member.OrderByDescending(x => x.Points);
                    Member = member.ToList().GetRange(member.ToList().FindIndex(x => x.Id == Int32.Parse(id)) - 1, 3);
                }
                else
                {
                    Member = (IList<Member>)Enumerable.Empty<Member>();
                    ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                }
            }

This is what I have got so far. I am able to display only the +1 from user and -1 from user. But the rank I have gotten was wrong.
<table class="table">
<thead>
    <tr>
        <th>
            Rank
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Member[0].UserName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Member[0].Points)
        </th>
    </tr>
</thead>
<tbody>
    @{int rank = 0;}
    @foreach (var item in Model.Member)
    {
        <tr>
            <td>
                @{rank++;}<label># @rank</label>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UserName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Points)
            </td>
        </tr>
    }
</tbody>

This is what I got for my cshtml page.
Thanks!

A:

just so i get the correct understanding are you after a leaderboard of 3 people?
so the member who is logged in with the member who sit above and below them in the leaderboard?
Looking at the api it looks like it takes in a memberId and returns that member only, are there any other apis? one that can get members by rank, or a list of members?

