AccessGrant GetGrant() { AccessGrant grant; switch (AccessLevel) { case PrivilegeAccessLevel.Read: grant = AccessGrant.ConstructGrantRead(); break; case PrivilegeAccessLevel.Update: grant = AccessGrant.ConstructGrantUpdate(); break; case PrivilegeAccessLevel.Create: grant = AccessGrant.ConstructGrantCreate(); break; case PrivilegeAccessLevel.Correct: grant = AccessGrant.ConstructGrantCorrect(); break; case PrivilegeAccessLevel.Delete: grant = AccessGrant.ConstructGrantDelete(); break; default: throw new NotImplementedException( $"Value {AccessLevel} is not implemented."); } return(grant); }
/// <summary> /// Executes routine /// </summary> public void run() { UserInterface userInterface = new UserInterface(); userInterface.ShowDialog(); if (!userInterface.closeOk) { return; } foreach (var item in userInterface.checkedItems()) { AccessGrant grant; string newName = string.Empty; string sufix = string.Empty; switch (item.ToString().ToUpper()) { case "UNSET": sufix = "Unset"; grant = AccessGrant.ConstructGrantAll(); break; case "NO ACCESS": sufix = "NoAccess"; grant = AccessGrant.ConstructDenyAll(); break; case "READ": sufix = "View"; grant = AccessGrant.ConstructGrantRead(); break; case "UPDATE": sufix = "Update"; grant = AccessGrant.ConstructGrantUpdate(); break; case "CREATE": sufix = "Create"; grant = AccessGrant.ConstructGrantCreate(); break; case "CORRECT": sufix = "Correct"; grant = AccessGrant.ConstructGrantCorrect(); break; case "DELETE": sufix = "Maintain"; grant = AccessGrant.ConstructGrantDelete(); break; default: throw new NotImplementedException($"Menu item object type {this.menuItem.ObjectType} is not implemented."); } newName = $"{this.menuItem.Name}{sufix}"; this.create(newName, grant); } }