protected void btnApply_Click(object sender, EventArgs e) { MembershipRole role = new MembershipRole(txtRoleName.Text, groupID); if (!Roles.RoleExists(txtRoleName.Text) && groupID == Guid.Empty) { Roles.CreateRole(txtRoleName.Text); } if (Roles.RoleExists(txtRoleName.Text) || groupID != Guid.Empty) { if (groupID == Guid.Empty) { role = SecurityData.FindMembershipRole(txtRoleName.Text); groupID = role.RoleId; } else { role = SecurityData.FindMembershipRole(groupID); } if (role != null && groupID != Guid.Empty) { if (CheckValidEditing(role.LoweredRoleName) && CheckValidEditing(txtRoleName.Text)) { role.RoleName = txtRoleName.Text; role.Save(); } if (CheckValidEditing(role.LoweredRoleName) && !CheckValidEditing(txtRoleName.Text)) { txtRoleName.Text = role.RoleName; } } Response.Redirect(SiteData.CurrentScriptName + "?id=" + groupID.ToString()); } }
public static MembershipRole FindMembershipRole(Guid roleID) { MembershipRole role = null; using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { role = (from r in _db.aspnet_Roles where r.RoleId == roleID select new MembershipRole(r)).FirstOrDefault(); } return(role); }
public static MembershipRole FindMembershipRole(string roleName) { MembershipRole role = null; using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { role = (from r in _db.aspnet_Roles where r.LoweredRoleName == roleName select new MembershipRole(r)).FirstOrDefault(); } return(role); }