//Get Index page public ActionResult Index() { var userRoles = new List<RolesViewModel>(); var userStore = new UserStore<ApplicationUser>(context); var userManager = new UserManager<ApplicationUser>(userStore); //Get all the usernames foreach (var user in userStore.Users) { var r = new RolesViewModel { UserName = user.UserName }; userRoles.Add(r); } //Get all the Roles for our users foreach (var user in userRoles) { user.RoleNames = userManager.GetRoles(userStore.Users.First(s => s.UserName == user.UserName).Id); if (user.RoleNames.Contains("Default")) { TempData["ValidationMessageIcon"] = "1"; } } return View(db.Indices.ToList()); }
public ActionResult Index() { var userRoles = new List<RolesViewModel>(); var userStore = new UserStore<ApplicationUser>(context); var userManager = new UserManager<ApplicationUser>(userStore); //Get all the usernames foreach (var user in userStore.Users) { var r = new RolesViewModel { UserName = user.UserName }; userRoles.Add(r); } //Get all the Roles for our users var numberOfDefault = 0; foreach (var user in userRoles) { user.RoleNames = userManager.GetRoles(userStore.Users.First(s => s.UserName == user.UserName).Id); if(user.RoleNames.Contains("Default")) { numberOfDefault++; TempData["ValidationMessageDefaultUser"] = numberOfDefault + " " + "New User(s) Have Registered"; TempData["ValidationMessageIcon"] = "1"; } } return View(userRoles); }