/// <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> 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> /// UpdateFieldsForSections /// </summary> /// <param name="companyId">companyId</param> /// <param name="currentProjectId">currentProjectId</param> private void UpdateFieldsForSections(int companyId, int currentProjectId) { AssetSewerSectionGateway assetSewerFindSectionGateway = new AssetSewerSectionGateway(); AssetSewerMHGateway assetSewerFindMHGateway = new AssetSewerMHGateway(); WorkGateway workGateway = new WorkGateway(); foreach (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORRow row in (ProjectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATORDataTable)Table) { //General data for asset assetSewerFindSectionGateway.LoadByAssetId(row.AssetID, companyId); //COMPANY_ID // ... For usmh row.USMHDescription = ""; if (!row.IsUSMHNull()) { assetSewerFindMHGateway.LoadByAssetId(row.USMH, companyId); row.USMHDescription = assetSewerFindMHGateway.GetMHID(row.USMH); } // ... For dsmh row.DSMHDescription = ""; if (!row.IsDSMHNull()) { assetSewerFindMHGateway.LoadByAssetId(row.DSMH, companyId); row.DSMHDescription = assetSewerFindMHGateway.GetMHID(row.DSMH); } // ... For Works row.RehabAssessment = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Rehab Assessment", companyId); row.FullLengthLining = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Full Length Lining", companyId); row.JunctionLining = workGateway.ExistsProjectIdAssetIdWorkTypeCompanyId(row.AssetID, currentProjectId, "Junction Lining Section", companyId); row.WorksDescription = ""; if (row.RehabAssessment) row.WorksDescription = row.WorksDescription + "Rehab Assessment"; if (row.FullLengthLining) { if (row.WorksDescription.Trim().Length > 0) { row.WorksDescription = row.WorksDescription + ", Full Length Lining"; } else { row.WorksDescription = row.WorksDescription + "Full Length Lining"; } } if (row.JunctionLining) { if (row.WorksDescription.Trim().Length > 0) { row.WorksDescription = row.WorksDescription + ", Junction Lining"; } else { row.WorksDescription = row.WorksDescription + "Junction Lining"; } } // ... For Laterals AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadBySectionId(row.AssetID, companyId); AssetSewerLateral assetSewerLateral = new AssetSewerLateral(assetSewerLateralGateway.Data); row.LateralsDescription = assetSewerLateral.GetAllLaterals(row.AssetID, companyId); } }