//Add Data From Linked Tables for Display public void EditForDisplay(ClientSubUnitClientAccount clientSubUnitClientAccount) { ClientAccountRepository clientAccountRepository = new ClientAccountRepository(); ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(clientSubUnitClientAccount.ClientAccountNumber, clientSubUnitClientAccount.SourceSystemCode); if (clientAccount != null) { clientSubUnitClientAccount.ClientAccountName = clientAccount.ClientAccountName; } ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository(); ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitClientAccount.ClientSubUnitGuid); if (clientSubUnit != null) { clientSubUnitClientAccount.ClientSubUnitName = clientSubUnit.ClientSubUnitName; } ConfidenceLevelForLoadRepository confidenceLevelForLoadRepository = new ConfidenceLevelForLoadRepository(); ConfidenceLevelForLoad confidenceLevelForLoad = new ConfidenceLevelForLoad(); if (clientSubUnitClientAccount.ConfidenceLevelForLoadId != null) { int confidenceLevelForLoadId = (int)clientSubUnitClientAccount.ConfidenceLevelForLoadId; confidenceLevelForLoad = confidenceLevelForLoadRepository.GetConfidenceLevelForLoad(confidenceLevelForLoadId); if (confidenceLevelForLoad != null) { clientSubUnitClientAccount.ConfidenceLevelForLoadDescription = confidenceLevelForLoad.ConfidenceLevelForLoadDescription; } } LineOfBusinessRepository lineOfBusinessRepository = new LineOfBusinessRepository(); LineOfBusiness lineOfBusiness = new LineOfBusiness(); if (clientSubUnitClientAccount.ClientAccountLineOfBusinessId != null) { int lineOfBusinessId = (int)clientSubUnitClientAccount.ClientAccountLineOfBusinessId; lineOfBusiness = lineOfBusinessRepository.GetLineOfBusiness(lineOfBusinessId); if (lineOfBusiness != null) { clientSubUnitClientAccount.LineOfBusiness = lineOfBusiness; } } }
//Get one Item public ClientSubUnit GetClientSubUnit(string id) { ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = db.ClientSubUnits.SingleOrDefault(c => c.ClientSubUnitGuid == id); if (clientSubUnit != null) { //RestrictedClientFlag ClientSubUnitAttribute clientSubUnitAttributeRestrictedClient = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "RestrictedClientFlag"); if (clientSubUnitAttributeRestrictedClient != null && clientSubUnitAttributeRestrictedClient.AttributeValue != null) { //Attribute saved as a varchar clientSubUnit.RestrictedClient = (clientSubUnitAttributeRestrictedClient.AttributeValue == "1"); } //PrivateClientFlag ClientSubUnitAttribute clientSubUnitAttributePrivateClient = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "PrivateClientFlag"); if (clientSubUnitAttributePrivateClient != null && clientSubUnitAttributePrivateClient.AttributeValue != null) { //Attribute saved as a varchar clientSubUnit.PrivateClient = (clientSubUnitAttributePrivateClient.AttributeValue == "1"); } //CubaBookingAllowedFlag ClientSubUnitAttribute cubaBookingAllowedFlag = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "CubaBookingAllowedFlag"); if (cubaBookingAllowedFlag != null && cubaBookingAllowedFlag.AttributeValue != null) { //Attribute saved as a varchar clientSubUnit.CubaBookingAllowed = (cubaBookingAllowedFlag.AttributeValue == "1"); } //InCountryServiceOnlyFlag ClientSubUnitAttribute inCountryServiceOnlyFlag = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "InCountryServiceOnlyFlag"); if (inCountryServiceOnlyFlag != null && inCountryServiceOnlyFlag.AttributeValue != null) { //Attribute saved as a varchar clientSubUnit.InCountryServiceOnly = (inCountryServiceOnlyFlag.AttributeValue == "1"); } //24HourServiceCenterTelephoneNumber ClientSubUnitAttribute clientSubUnitAttribute24Hours = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "24HourServiceCenterTelephoneNumber"); if (clientSubUnitAttribute24Hours != null && clientSubUnitAttribute24Hours.AttributeValue != null) { clientSubUnit.DialledNumber24HSC = clientSubUnitAttribute24Hours.AttributeValue; } //Line of Business ClientSubUnitLineOfBusinessRepository clientSubUnitLineOfBusinessRepository = new ClientSubUnitLineOfBusinessRepository(); ClientSubUnitLineOfBusiness clientSubUnitLineOfBusiness = clientSubUnitLineOfBusinessRepository.GetClientSubUnitLineOfBusiness(clientSubUnit.ClientSubUnitGuid); if (clientSubUnitLineOfBusiness != null) { LineOfBusinessRepository lineOfBusinessRepository = new LineOfBusinessRepository(); LineOfBusiness lineOfBusiness = lineOfBusinessRepository.GetLineOfBusiness(clientSubUnitLineOfBusiness.LineOfBusinessId); if (lineOfBusiness != null) { clientSubUnit.LineOfBusiness = lineOfBusiness; } clientSubUnit.LineOfBusinessId = clientSubUnitLineOfBusiness.LineOfBusinessId; } //BranchContactNumber ClientSubUnitAttribute clientSubUnitAttributeBranchContactNumber = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "BranchContactNumber"); if (clientSubUnitAttributeBranchContactNumber != null && clientSubUnitAttributeBranchContactNumber.AttributeValue != null) { clientSubUnit.BranchContactNumber = clientSubUnitAttributeBranchContactNumber.AttributeValue; } //BranchFaxNumber ClientSubUnitAttribute clientSubUnitAttributeBranchFaxNumber = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "BranchFaxNumber"); if (clientSubUnitAttributeBranchFaxNumber != null && clientSubUnitAttributeBranchFaxNumber.AttributeValue != null) { clientSubUnit.BranchFaxNumber = clientSubUnitAttributeBranchFaxNumber.AttributeValue; } //BranchEmail ClientSubUnitAttribute clientSubUnitAttributeBranchEmail = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "BranchEmail"); if (clientSubUnitAttributeBranchEmail != null && clientSubUnitAttributeBranchEmail.AttributeValue != null) { clientSubUnit.BranchEmail = clientSubUnitAttributeBranchEmail.AttributeValue; } //ClientIATA ClientSubUnitAttribute clientSubUnitAttributeClientIATA = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "ClientIATA"); if (clientSubUnitAttributeClientIATA != null && clientSubUnitAttributeClientIATA.AttributeValue != null) { clientSubUnit.ClientIATA = clientSubUnitAttributeClientIATA.AttributeValue; } //PortraitStatusDescription ClientSubUnitAttribute clientSubUnitAttributePortraitStatusDescription = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "PortraitStatusDescription"); if (clientSubUnitAttributePortraitStatusDescription != null && clientSubUnitAttributePortraitStatusDescription.AttributeValue != null) { clientSubUnit.PortraitStatusDescription = clientSubUnitAttributePortraitStatusDescription.AttributeValue; } //ClientBusinessDescription ClientSubUnitAttribute clientSubUnitAttributeClientBusinessDescription = clientSubUnitAttributeRepository.GetClientSubUnitAttributeByType(clientSubUnit.ClientSubUnitGuid, "ClientBusinessDescription"); if (clientSubUnitAttributeClientBusinessDescription != null && clientSubUnitAttributeClientBusinessDescription.AttributeValue != null) { clientSubUnit.ClientBusinessDescription = clientSubUnitAttributeClientBusinessDescription.AttributeValue; } } return(clientSubUnit); }