private StringBuilder BuildFileContent(List <Type814Header> headers, CspDunsPortModel cspDunsPort) { var ldcModel = clientDataAccess.LoadLdcById(cspDunsPort.LdcId.HasValue ? cspDunsPort.LdcId.Value: 0); var contentBuilder = new StringBuilder(); var rootLevelColumns = string.Format("{0},{1},{2}", "LdcDuns", "LdcName", "CspDuns"); var rootLevelData = string.Format("{0},{1},{2}", cspDunsPort.LdcDuns, ldcModel.LdcName, cspDunsPort.Duns); var headerLines = GetHeaderLines(headers); for (var i = 0; i < headerLines.Count; i++) { //header row if (i == 0) { //add header row contentBuilder.AppendLine(string.Format("{0},{1}", rootLevelColumns, headerLines[i])); } else { //add data rows contentBuilder.AppendLine(string.Format("{0},{1}", rootLevelData, headerLines[i])); } } return(contentBuilder); }
public CspDunsPortModel IdentifyCspDunsPort(CspDunsPortModel[] cspDunsPorts, int cspDunsId) { var port = cspDunsPorts .Where(x => x.CspDunsId.Equals(cspDunsId)) .FirstOrDefault(x => !x.LdcId.HasValue || x.LdcId == 0); if (port != null) { return(port); } var ldcIdentifiers = cspDunsPorts .Where(x => x.LdcId.HasValue) .Select(x => x.LdcId ?? 0) .Distinct(); foreach (var ldcIdentifier in ldcIdentifiers) { var ldcModel = clientDataAccess.LoadLdcById(ldcIdentifier); if (ldcModel == null) { continue; } var market = (MarketOptions)ldcModel.MarketId; if (market != MarketOptions.Texas) { continue; } port = cspDunsPorts.FirstOrDefault(x => x.LdcId.Equals(ldcIdentifier)); break; } return(port); }