void MarkSelectedRoles() { RoleVMs.Clear(); foreach (var role in Roles) { var rolevm = new RoleVM { Id = role.Id, Name = role.Name }; RoleVMs.Add(rolevm); } if (User.Roles != null) { foreach (var role in User.Roles) { if (RoleVMs.Find(r => r.Id == role.RoleId) != null) { RoleVMs.Find(r => r.Id == role.RoleId).Checked = true; } } } if (string.IsNullOrEmpty(User.UserName)) { if (RoleVMs.Find(r => r.Name.ToLower() == "user") != null) { RoleVMs.Find(r => r.Name.ToLower() == "user").Checked = true; } } GetAllSelections(); }
protected void CheckboxClicked(ChangeEventArgs e, string id) { if (RoleVMs.Find(r => r.Id == id) != null) { bool Checked = RoleVMs.Find(r => r.Id == id).Checked; RoleVMs.Find(r => r.Id == id).Checked = !Checked; GetAllSelections(); } }