I am trying to display all objects´ properties of a List in different labels grouped by one of their properties.
Here is my class definition:
public class User
{
public string Username { get; set; }
public string IP { get; set; }
public string Levels { get; set; }
}
Here I deserialize users into the List bringing them from http request to API:
var users = new List<User>();
for (int i = 0; i < cuenta; i++)
{
await getAllUsers(i,users);
}
private async Task getAllUsers(int count, List<User> users)
{
var requestURI = new HttpRequestMessage();
string url = "https:...;
requestURI.RequestUri = new Uri(url);
requestURI.Method = HttpMethod.Get;
requestURI.Headers.Add("Accept", "application/json");
HttpResponseMessage responseURI = await client.SendAsync(requestURI);
if (responseURI.StatusCode == HttpStatusCode.OK)
{
Debug.WriteLine("Get Users OK");
var UserString = await responseURI.Content.ReadAsStringAsync();
Debug.WriteLine("Users in DLT: " + UserString);
var userGET = JsonConvert.DeserializeObject<User>(UserString);
users.Add(userGET);
Debug.WriteLine(users[0].IP); // Works correct
}
else
{
Debug.WriteLine("Users GET request failed");
}
}
I would like to display all users properties (Username, IP and Levels) of the list "users" in different labels grouped by the different levels of them.