public IEnumerable <ZipCodeData> GetZips(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); var zips = zipCodeRepository.GetByState(state); if (zips != null) { foreach (ZipCode zipCode in zips) { zipCodeData.Add(new ZipCodeData() { City = zipCode.City, State = zipCode.State.Abbreviation, ZipCode = zipCode.Zip }); } } Console.WriteLine("GetZips(state) called here."); return(zipCodeData); }
public List <ZipCodeData> GetZipCodes(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository(); List <ZipCode> zipCodeList = zipCodeRepository.GetByState(state); // ReSharper disable once InvertIf if (zipCodeList != null && zipCodeList.Count > 0) { // ReSharper disable once LoopCanBeConvertedToQuery foreach (ZipCode zipCode in zipCodeList) { ZipCodeData newZipCodeData = new ZipCodeData { City = zipCode.City, State = zipCode.State.Abbreviation, ZipCode = zipCode.Zip }; zipCodeData.Add(newZipCodeData); } } else { string message = $"State {state} not found"; throw new FaultException(message); } return(zipCodeData); }
public List <ZipCodeData> GetZipCodes(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository(); List <ZipCode> zipCodes = zipCodeRepository.GetByState(state); // ReSharper disable once InvertIf if (zipCodes != null) { // ReSharper disable once LoopCanBeConvertedToQuery foreach (ZipCode zipCode in zipCodes) { ZipCodeData newZipCodeData = new ZipCodeData { City = zipCode.City, State = zipCode.State.Abbreviation, ZipCode = zipCode.Zip }; zipCodeData.Add(newZipCodeData); } } return(zipCodeData); }
public IEnumerable <ZipCodeData> GetZip(string state) { IZipCodeRepository rep = _repZip ?? new ZipCodeRepository(); IEnumerable <ZipCode> zipCodes = rep.GetByState(state); IEnumerable <ZipCodeData> result = zipCodes.Select(s => new ZipCodeData { State = s.State.Abbreviation, ZipCode = s.Zip, City = s.City }).ToList(); return(result); }
public IEnumerable <ZipCodeData> GetZips(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); var zips = zipCodeRepository.GetByState(state); if (zips != null) { zipCodeData.AddRange(zips.Select(zipCode => new ZipCodeData { City = zipCode.City, State = zipCode.State.Abbreviation, ZipCode = zipCode.Zip })); } return(zipCodeData); }
public IEnumerable <ZipCodeData> GetZips(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository(); var zips = zipCodeRepository.GetByState(state); if (zips != null) { foreach (ZipCode zipCode in zips) { zipCodeData.Add(LocalConfiguration.Mapper.Map <ZipCodeData>(zipCode)); } } return(zipCodeData); }
public IEnumerable <ZipCodeData> GetZips(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); var zips = _zipCodeRepo.GetByState(state); foreach (var zip in zips) { zipCodeData.Add(new ZipCodeData() { City = zip.City, State = zip.State.Abbreviation, ZipCode = zip.Zip }); } return(zipCodeData); }
public IEnumerable <ZipCodeData> GetZips(string state) { List <ZipCodeData> zipCodeData = new List <ZipCodeData>(); IZipCodeRepository repository = zipCodeRepository ?? new ZipCodeRepository(); var zips = repository.GetByState(state); if (zips != null) { foreach (var zipCode in zips) { zipCodeData.Add(new ZipCodeData() { City = zipCode.City, State = zipCode.State.Abbreviation, ZipCode = zipCode.Zip }); } } return(zipCodeData); }
public IEnumerable <ZipCode> GetZips(string state) { IEnumerable <ZipCode> zips = _ZipCodeRepository.GetByState(state); return(zips); }