Example #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));
        }
Example #2
0
        /// <summary>
        /// Add this Asset Type to the database (or possibly update an existing item)
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            AssetTypesDAO lwDataAccess = new AssetTypesDAO();

            if (AssetTypeID == 0)
            {
                lwDataAccess.AssetTypeAdd(this);
            }
            else
            {
                lwDataAccess.AssetTypeUpdate(this);
            }
            return(0);
        }
Example #3
0
        public int Populate()
        {
            // Ensure that the list is empty initially
            this.Clear();

            AssetTypesDAO lwDataAccess = new AssetTypesDAO();
            DataTable     table        = lwDataAccess.EnumerateAssetTypes();

            // Iterate through the returned rows in the table and create AssetType objects for each
            foreach (DataRow row in table.Rows)
            {
                AddAssetType(row);
            }
            return(this.Count);
        }
Example #4
0
 public Asset(AuditDataFile auditDataFile) : this()
 {
     UniqueID     = auditDataFile.Uniqueid;
     Name         = auditDataFile.AssetName;
     Domain       = auditDataFile.Domain;
     IPAddress    = auditDataFile.Ipaddress;
     LastAudit    = auditDataFile.AuditDate;
     Location     = auditDataFile.Location;
     MACAddress   = auditDataFile.Macaddress;
     Make         = auditDataFile.Make;
     Model        = auditDataFile.Model;
     SerialNumber = auditDataFile.Serial_number;
     AgentVersion = auditDataFile.AgentVersion;
     AssetTypeID  = new AssetTypesDAO().GetAssetTypeIDByName(auditDataFile.Category);
     TypeAsString = auditDataFile.Category;
     AssetTag     = auditDataFile.AssetTag;
 }