/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> /// <returns></returns> public bool DeleteDirect(int assetId, int companyId) { // Verify in use if (!InUse(assetId, companyId)) { // Delete laterals // ... Define initial models LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); // ... Load laterals AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadBySectionId(assetId, companyId); // ... Delete laterals foreach (AssetsTDS.AM_ASSET_SEWER_LATERALRow rowLateral in (AssetsTDS.AM_ASSET_SEWER_LATERALDataTable)assetSewerLateralGateway.Table) { lfsAssetSewerLateral.DeleteDirect(rowLateral.AssetID, companyId); } // Get MHs for deleted AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(assetId, companyId); int? usmh_assetId = assetSewerSectionGateway.GetUSMH(assetId); int? dsmh_assetId = assetSewerSectionGateway.GetDSMH(assetId); // Delete section LfsAssetSewerSectionGateway lfsAssetSewerSectionGateway = new LfsAssetSewerSectionGateway(null); lfsAssetSewerSectionGateway.Delete(assetId, companyId); LfsAssetSewer lfsAssetSewer = new LfsAssetSewer(null); lfsAssetSewer.DeleteDirect(assetId, companyId); LfsAsset lfsAsset = new LfsAsset(null); lfsAsset.DeleteDirect(assetId, companyId); // delete section in AM tables AssetSewerSection assetSewerSection = new AssetSewerSection(null); assetSewerSection.DeleteDirect(assetId, companyId); // Delete USMH (if not in use) if (usmh_assetId.HasValue) { LfsAssetSewerMH lfsAssetSewerUsmh = new LfsAssetSewerMH(null); lfsAssetSewerUsmh.DeleteDirect((int)usmh_assetId, companyId); } // Delete DSMH (if not in use) if (dsmh_assetId.HasValue) { LfsAssetSewerMH lfsAssetSewerDsmh = new LfsAssetSewerMH(null); lfsAssetSewerDsmh.DeleteDirect((int)dsmh_assetId, companyId); } return true; } else { return false; } }
/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> /// <returns></returns> public bool DeleteDirect(int assetId, int companyId) { // verify use if (!InUse(assetId, companyId)) { // delete in LFS tables LfsAssetSewerMHGateway lfsAssetSewerMHGateway = new LfsAssetSewerMHGateway(null); lfsAssetSewerMHGateway.Delete(assetId, companyId); LfsAssetSewer lfsAssetSewer = new LfsAssetSewer(null); lfsAssetSewer.DeleteDirect(assetId, companyId); LfsAsset lfsAsset = new LfsAsset(null); lfsAsset.DeleteDirect(assetId, companyId); // delete in AM tables AssetSewerMH assetSewerMh = new AssetSewerMH(null); assetSewerMh.DeleteDirect(assetId, companyId); return true; } else { return false; } }