/// <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; } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Delete /// </summary> /// <param name="workId">workId</param> /// <param name="companyId">companyId</param> public void Delete(int workId, int companyId) { WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateway.LoadByWorkId(workId, companyId); foreach (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALRow row in (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALDataTable)workFullLengthLiningM1LateralGateway.Table) { // delete lfs lateral client WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(workId, companyId); int currentProjectId = workGateway.GetProjectId(workId); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(row.Lateral, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(row.Lateral, clientId, companyId); } // Delete work lateral workFullLengthLiningM1LateralGateway.Delete(workId, row.Lateral, companyId); // Delete section LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); lfsAssetSewerLateral.DeleteDirect(row.Lateral, companyId); } }
/// <summary> /// Delete /// </summary> /// <param name="workId">workId</param> /// <param name="assetIdLateral">assetIdLateral</param> /// <param name="sectionWorkId">sectionWorkId</param> /// <param name="companyId">companyId</param> private void Delete(int workId, int assetIdLateral, int sectionWorkId, int companyId) { WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(workId, companyId); int currentProjectId = workGateway.GetProjectId(workId); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); // delete lateral work WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null); workJunctionLiningLateral.DeleteDirect(workId, sectionWorkId, companyId); // delete lfs lateral LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); bool isDeleted = lfsAssetSewerLateral.DeleteDirect(assetIdLateral, companyId); if (isDeleted) { // delete lfs lateral client LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(assetIdLateral, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(assetIdLateral, clientId, companyId); } } }
/// <summary> /// Delete lateral work /// </summary> /// <param name="workId">workId</param> /// <param name="lateral">lateral</param> /// <param name="companyId">companyId</param> /// <param name="projectId">projectId</param> private void DeleteFLLLateral(int workId, int lateral, int companyId, int projectId) { // Delete work lateral WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null); workFullLengthLiningM1Lateral.DeleteDirect(workId, lateral, companyId); // Delete section LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); bool isDeleted = lfsAssetSewerLateral.DeleteDirect(lateral, companyId); if (isDeleted) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(lateral, clientId, companyId); } }
/// <summary> /// Delete lateral work /// </summary> /// <param name="workId">workId</param> /// <param name="lateral">lateral</param> /// <param name="companyId">companyId</param> /// <param name="clientId">clientId</param> private void DeleteFLLLateral(int workId, int lateral, int companyId, int clientId) { // Delete work lateral WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null); workFullLengthLiningM1Lateral.DeleteDirect(workId, lateral, companyId); // Delete section LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); bool isDeleted = lfsAssetSewerLateral.DeleteDirect(lateral, companyId); if (isDeleted) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(lateral, clientId, companyId); } }