/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> public bool DeleteDirect(int assetId, int companyId) { // Delete laterals // ... Define initial models AssetSewerLateral assetSewerLateral = new AssetSewerLateral(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) { assetSewerLateral.DeleteDirect(rowLateral.AssetID, companyId); } // Delete section AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(null); assetSewerSectionGateway.Delete(assetId, companyId); AssetSewer assetSewer = new AssetSewer(null); assetSewer.DeleteDirect(assetId, companyId); Asset asset = new Asset(null); asset.DeleteDirect(assetId, companyId); return true; }
/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> public bool DeleteDirect(int assetId, int companyId) { // Get initial data AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadByAssetId(assetId, companyId); int section_ = assetSewerLateralGateway.GetSection(assetId); string state = assetSewerLateralGateway.GetState(assetId); // Delete lateral assetSewerLateralGateway.Delete(assetId, companyId); AssetSewer assetSewer = new AssetSewer(null); assetSewer.DeleteDirect(assetId, companyId); Asset asset = new Asset(null); asset.DeleteDirect(assetId, companyId); // Update Section // ... Load section AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(section_, companyId); // ... Get old values of section string sectionIdS = assetSewerSectionGateway.GetSectionId(section_); string streetS = assetSewerSectionGateway.GetStreet(section_); int? usmhIdS = assetSewerSectionGateway.GetUSMH(section_); int? dsmhIdS = assetSewerSectionGateway.GetDSMH(section_); string mapSizeS = assetSewerSectionGateway.GetMapSize(section_); string size_S = assetSewerSectionGateway.GetSize_(section_); string mapLengthS = assetSewerSectionGateway.GetMapSize(section_); string lengthS = assetSewerSectionGateway.GetLength(section_); int? lateralsS = assetSewerSectionGateway.GetLaterals(section_); int? liveLateralsS = assetSewerSectionGateway.GetLiveLaterals(section_); string flowDirectionS = assetSewerSectionGateway.GetFlowDirection(section_); string usmhDepthS = assetSewerSectionGateway.GetUSMHDepth(section_); string dsmhDepthS = assetSewerSectionGateway.GetDSMHDepth(section_); bool deletedS = assetSewerSectionGateway.GetDeleted(section_); string flowOrderIdS = assetSewerSectionGateway.GetFlowOrderID(section_); // ... Calculate new values of section int? newLaterals = lateralsS - 1; int? newLiveLaterals = liveLateralsS; if ((newLiveLaterals.HasValue) && (state == "Live")) { newLiveLaterals = newLiveLaterals - 1; } // ... Update section AssetSewerSection assetSewerSection = new AssetSewerSection(assetSewerSectionGateway.Data); assetSewerSection.UpdateDirect(section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, lateralsS, liveLateralsS, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS, section_, sectionIdS, streetS, usmhIdS, dsmhIdS, mapSizeS, size_S, mapLengthS, lengthS, newLaterals, newLiveLaterals, flowDirectionS, usmhDepthS, dsmhDepthS, deletedS, companyId, flowOrderIdS); return true; }
/// <summary> /// DeleteDirect /// </summary> /// <param name="assetId">assetId</param> /// <param name="companyId">companyId</param> public bool DeleteDirect(int assetId, int companyId) { if (!InUse(assetId, companyId)) { AssetSewerMHGateway assetSewerMhGateway = new AssetSewerMHGateway(null); assetSewerMhGateway.Delete(assetId, companyId); AssetSewer assetSewer = new AssetSewer(null); assetSewer.DeleteDirect(assetId, companyId); Asset asset = new Asset(null); asset.DeleteDirect(assetId, companyId); return true; } else { return false; } }