// GET: Admin /// <summary> /// List all user accounts /// </summary> /// <returns></returns> public ActionResult Index() { // Status message //ViewBag.StatusMessage = // message == ManageMessageId.ChangeUserInfoSuccess ? "User has been updated." // : message == ManageMessageId.DeleteUserSuccess ? "User's Account has been deleted." // : message == ManageMessageId.Error ? "An error has occurred." // : message == ManageMessageId.SetAsAdminSuccess ? "User set as Admin." // : message == ManageMessageId.RemoveAsAdminSuccess ? "Admin role has been removed" // : ""; IEnumerable <Account> accounts = _proxy.GetAccounts(); // Create a list with just user accounts, not including accounts with Admin role ICollection <DisplayUserModel> displayUserModels = new List <DisplayUserModel>(); foreach (Account account in accounts) { bool isAdmin = _proxy.IsInRole(account.Id, "admin"); if (account.Id.ToString() != User.Identity.GetUserId()) { displayUserModels.Add(new DisplayUserModel { Id = account.Id, Email = account.Email, UserName = account.Username, IsAdmin = isAdmin }); } } return(View(displayUserModels)); }
public ActionResult HighScores() { IEnumerable <Account> accounts = _proxy.GetAccounts(); ICollection <HighScoreModel> highScoreModels = new List <HighScoreModel>(); //TODO: Uncomment once we have highscores for the users //Dictionary<Guid , int> highScores= _highScoreProxy.GetHighscores(); // foreach(KeyValuePair<Guid,int> kvp in highScores) // { // HighScoreModel hm = new HighScoreModel { UserName = _proxy.FindById(kvp.Key).Username, HighScore = kvp.Value }; // highScoreModels.Add(hm); // } Random rnd = new Random(); int rank = 0; foreach (Account account in accounts) { rank++; highScoreModels.Add(new HighScoreModel { Rank = rank, UserName = account.Username, HighScore = rnd.Next(1, 9999) }); } return(View(highScoreModels)); }