private void ToggleAssetTypeFilters() { // Get the asset type var assetType = AssetType.Get(AssetTypeDropDownList1.SelectedId); MetadataFilters.ToggleAssetTypeFilters(assetType); }
public static void DeleteAssetType(int assetTypeId) { AssetType at = AssetType.Get(assetTypeId); if (at.AssetTypeFileExtensionList.Count > 0) { throw new SystemException("This asset type cannot be deleted as it has file extensions assigned to it"); } AssetFinder finder = new AssetFinder { AssetTypeId = assetTypeId }; int count = Asset.GetCount(finder); if (count > 0) { throw new SystemException("This asset type cannot be deleted as assets of this type have been uploaded"); } at.IsDeleted = true; AssetType.Update(at); CacheManager.InvalidateCache("AssetType", CacheType.All); }
protected override void Grid_UpdateCommand(object source, DataGridCommandEventArgs e) { int assetTypeId = Convert.ToInt32(e.CommandArgument); TextBox NameTextBox = (TextBox)e.Item.FindControl("NameTextBox"); CheckBox IsVisibleCheckBox = (CheckBox)e.Item.FindControl("IsVisibleCheckBox"); try { AssetType assetType = AssetType.Get(assetTypeId); assetType.Name = NameTextBox.Text.Trim(); assetType.IsVisible = IsVisibleCheckBox.Checked; AssetTypeManager.SaveAssetType(assetType); AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ModifyAssetType, string.Format("Modified Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetType.AssetTypeId)); ResetGridState(); MessageLabel1.SetSuccessMessage("Asset type updated successfully"); } catch (InvalidAssetTypeException imtex) { MessageLabel1.SetErrorMessage("Unable to update asset type", imtex.Message); BindGrid(CurrentPage); } }