Ejemplo n.º 1
0
        protected int Delete(AssetType assettype)
        {
            AssetTypesDAO lwDataAccess = new AssetTypesDAO();

            // If this is a category then we need to delete each of the sub-types first
            if (assettype.ParentID == 0)
            {
                AssetTypeList listAssetTypes = new AssetTypeList();
                listAssetTypes.Populate();
                AssetTypeList listSubTypes = listAssetTypes.EnumerateChildren(AssetTypeID);

                // Loop through the sub-types returned and try and delete them
                foreach (AssetType subType in listSubTypes)
                {
                    // Error if we failed to delete - we cannot delete the parent then
                    if (this.Delete(subType) != 0)
                    {
                        return(-1);
                    }
                }
            }

            // Delete the asset type
            return(lwDataAccess.AssetTypeDelete(this));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Does this user data category apply to this asset?
        /// </summary>
        /// <param name="asset"></param>
        /// <returns>true if yes, false otherwise</returns>
        public bool CategoryAppliesTo(Asset asset)
        {
            if (_listAssetTypes == null)
            {
                _listAssetTypes = new AssetTypeList();
                _listAssetTypes.Populate();
            }

            // Is this category specific to an asset type?
            if (AppliesTo != 0)
            {
                // OK - does the category apply specifically to this asset type?
                if (AppliesTo != asset.AssetTypeID)
                {
                    // No - we need to get the parent category of this asset type and check that also then
                    AssetType parentType = _listAssetTypes.FindByName(asset.TypeAsString);
                    if ((parentType == null) || (_appliesTo != parentType.ParentID))
                    {
                        return(false);
                    }
                }
            }

            // User data category applies to this type of asset so return true
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return a list of the child asset types of the specified category
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public AssetTypeList EnumerateChildren(int category)
        {
            AssetTypeList children = new AssetTypeList();

            foreach (AssetType assettype in this)
            {
                if (assettype.ParentID == category)
                {
                    children.Add(assettype);
                }
            }
            return(children);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Return a list of the Asset Type Categories
        /// </summary>
        /// <returns></returns>
        public AssetTypeList EnumerateCategories()
        {
            AssetTypeList categories = new AssetTypeList();

            foreach (AssetType assettype in this)
            {
                if (assettype.ParentID == 0)
                {
                    categories.Add(assettype);
                }
            }
            return(categories);
        }