/// <summary> /// The method to get all users of the database /// </summary> /// <param name="username">the user username</param> /// <returns>a list of the all usernames of the database</returns> private async Task <List <string> > GetAllUsers(string username) { UserDimension usersDim = await Services.GetAllUsers(); List <UserDim> allUsers = usersDim.users; List <string> usernames = new List <string>(); foreach (UserDim item in allUsers) { if (item.user != username) { usernames.Add(item.user); } } return(usernames); }
// GET: /Statistics public async Task <ActionResult> Statistics() { UserDimension users = await Services.GetAllUsers(); ViewBag.Dimension = users.users.Count; UserDimension userStrenght = await Services.GetAllUsersStrenght(); ViewBag.Strenght = userStrenght.users; ViewBag.Users = users.users; ViewBag.AnomUserTag = GetOverallUserTagCount(users.users.Count); ViewBag.AnomConnTag = await GetOverallConnectionTagCount(); // authenticated users string userID = User.Identity.GetUserId(); if (userID != null && User.IsInRole("User")) { ApplicationUser user = db.Users.Find(userID); UserGraph graph = await Services.GetUserGraph(user.UserName); int nrFriends = graph.nodes.Count; ViewBag.nrFriends = nrFriends; if (nrFriends > 0) { ViewBag.AuthConnTag = await GetAuthenticatedConnectionTagCount(user.UserName); List <string> friendIds = FindFriendIds(graph); ViewBag.AuthUserTag = GetAuthenticatedUserTagCount(graph.nodes.Count, friendIds); } } return(View()); }