private void UpdateUsersAndRoles() { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var roleStore = new RoleStore <IdentityRole>(new ApplicationDbContext()); var roleManager = new RoleManager <IdentityRole>(roleStore); if (!roleManager.RoleExists("NoRole")) { roleManager.Create(new IdentityRole("NoRole")); } var nonRoledUsers = (from user in manager.Users where user.Roles.Count == 0 orderby user.Email select user).ToList(); foreach (var user in nonRoledUsers) { manager.AddToRole(user.Id, "NoRole"); } var roles = (from role in roleManager.Roles orderby role.Name select role).ToRoleBindingList(); RolesAndUsersRepeater.DataSource = roles; RolesAndUsersRepeater.DataBind(); var users = (from user in manager.Users orderby user.Email select user).ToUserBindingList(); UserRepeater.DataSource = users; UserRepeater.DataBind(); }
protected void selectTable_SelectedIndexChanged(object sender, EventArgs e) { DietitianRepeater.Dispose(); DietitianRepeater.Visible = false; UserRepeater.Dispose(); UserRepeater.Visible = false; DietRepeater.Visible = false; BlogPostRepeater.Visible = false; PaymentRepeater.Visible = false; MedicalReportRepeater.Visible = false; AppointmentRepeater.Visible = false; DietRequestRepeater.Visible = false; DietViewRepeater.Visible = false; DietRepeater.Dispose(); BlogPostRepeater.Dispose(); PaymentRepeater.Dispose(); MedicalReportRepeater.Dispose(); AppointmentRepeater.Dispose(); DietRequestRepeater.Dispose(); DietViewRepeater.Dispose(); LogRepeater.Visible = false; LogRepeater.Dispose(); DropDownList drp = (DropDownList)sender; switch (drp.SelectedIndex) { case 1: UserRepeater.DataBind(); UserRepeater.Visible = true; break; case 2: DietitianRepeater.DataBind(); DietitianRepeater.Visible = true; break; case 3: AppointmentRepeater.DataBind(); AppointmentRepeater.Visible = true; break; case 4: PaymentRepeater.DataBind(); PaymentRepeater.Visible = true; break; case 5: MedicalReportRepeater.DataBind(); MedicalReportRepeater.Visible = true; break; case 6: DietRequestRepeater.DataBind(); DietRequestRepeater.Visible = true; break; case 7: DietRepeater.DataBind(); DietRepeater.Visible = true; break; case 8: BlogPostRepeater.DataBind(); BlogPostRepeater.Visible = true; break; case 9: DietViewRepeater.DataBind(); DietViewRepeater.Visible = true; break; case 10: LogRepeater.DataBind(); LogRepeater.Visible = true; break; } }
private void Populate() { UserRepeater.DataSource = StreamingLiveLib.Users.LoadBySiteId(AppUser.Current.Site.Id); UserRepeater.DataBind(); EditHolder.Visible = false; }