/// <summary> /// Saves the authentication scope. /// </summary> /// <param name="authScopeId">The authentication scope identifier.</param> private void SaveAuthScope(int authScopeId) { var isNew = authScopeId.Equals(0); var authScope = new AuthScope(); var editAllowed = authScope.IsAuthorized(Authorization.EDIT, CurrentPerson); if (!editAllowed) { DisplayErrorMessage("The current user is not authorized to make changes."); return; } var rockContext = new RockContext(); var authScopeService = new AuthScopeService(rockContext); if (isNew) { authScopeService.Add(authScope); } else { authScope = authScopeService.Get(authScopeId); } if (authScope == null) { DisplayErrorMessage("The Auth Scope with the specified Id was found."); return; } if (!authScope.IsSystem) { authScope.Name = tbName.Text; authScope.IsActive = cbActive.Checked; } authScope.PublicName = tbPublicName.Text; rockContext.SaveChanges(); }
/// <summary> /// Handles the Delete event of the gUserLogins control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param> protected void gAuthScopes_Delete(object sender, RowEventArgs e) { bool canEdit = IsUserAuthorized(Authorization.EDIT); if (canEdit) { using (var rockContext = new RockContext()) { var authScopeService = new AuthScopeService(rockContext); var authScope = authScopeService.Get(e.RowKeyId); if (authScope != null) { authScopeService.Delete(authScope); rockContext.SaveChanges(); } } } BindGrid(); }