/// <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> /// LateralUpdate /// </summary> /// <param name="currentProjectId">currentProjectId</param> /// <param name="assetId">assetId</param> /// <param name="distanceFromDsmh">distanceFromDsmh</param> /// <param name="distanceFromUsmh">distanceFromUsmh</param> /// <param name="mapSize">mapSize</param> /// <param name="companyId">companyId</param> /// <param name="clientLateralId">clientLateralId</param> /// <param name="address">address</param> /// <param name="connectionType">connectionType</param> private void LateralUpdate(int currentProjectId, int assetId, string distanceFromDsmh, string distanceFromUsmh, string mapSize, int companyId, string clientLateralId, string address, string connectionType) { AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadByAssetId(assetId, companyId); // original values int originalSection_ = assetSewerLateralGateway.GetSection(assetId); string originalAddress = assetSewerLateralGateway.GetAddress(assetId); string originalLateralId = assetSewerLateralGateway.GetLateralId(assetId); string originalLatitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(assetId); string originalLongitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(assetId); string originalLatitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(assetId); string originalLongitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(assetId); string originalState = assetSewerLateralGateway.GetState(assetId); string originalSize_ = assetSewerLateralGateway.GetSize(assetId); string originalDistanceFromUsmh = assetSewerLateralGateway.GetDistanceFromUSMH(assetId); string originalDistanceFromDsmh = assetSewerLateralGateway.GetDistanceFromDSMH(assetId); string originalMapSize = assetSewerLateralGateway.GetMapSize(assetId); bool originalDelete = assetSewerLateralGateway.GetDeleted(assetId); int originalCompanyId = assetSewerLateralGateway.GetCompanyId(assetId); string originalConnectionType = assetSewerLateralGateway.GetConnectionType(assetId); // new values string newAddress = address; string newDistanceFromUsmh = originalDistanceFromUsmh; string newDistanceFromDsmh = originalDistanceFromDsmh; string newMapSize = mapSize; string newConnectionType = connectionType; // Update Sewer lateral AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null); assetSewerLateral.UpdateDirect(assetId, originalSection_, originalAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, originalDistanceFromUsmh, originalDistanceFromDsmh, originalMapSize, originalDelete, originalCompanyId, originalConnectionType, assetId, originalSection_, newAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, newDistanceFromUsmh, newDistanceFromDsmh, newMapSize, originalDelete, originalCompanyId, newConnectionType); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadAllByAssetIdClientId(assetId, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count == 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(assetId, clientId, clientLateralId, false, companyId); } else { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); string originalClientLateralId = lfsAssetSewerLateralClientGateway.GetClientLateralId(assetId, clientId); string newClientLateralId = clientLateralId; lfsAssetSewerLateralClient.UpdateDirect(assetId, clientId, originalClientLateralId, false, companyId, assetId, clientId, newClientLateralId, false, companyId); } }