public void AddZipCodes() { var zip2list = _zipRepository2.GetAll(); foreach (var code2 in zip2list) { try { var city = _cityRepository.GetSingle(x => x.Name == code2.City); if (city != null) { ZipCodes code = new ZipCodes(); code.CityId = city.CityId; code.Number = Convert.ToInt32(code2.ZipCode); code.IsActive = true; code.IsDeleted = false; code.CreatedDate = DateTime.Now; _zipRepository.Add(code); } else { } } catch { continue; } } }
public MainResponse GetAllZipCodes(ZipCodeRequest request) { var zipCodes = _zipCodeRepository2.GetAll(x => x.City == request.cityname && x.StateAbbrv == request.statecode).OrderBy(x => x.ZipCode); var zipCodeResponse = _mapper.Map <List <GetZipCodes> >(zipCodes); ZipCodeResponse response = new ZipCodeResponse(); response.ZipCode = zipCodeResponse; _mainResponse.ZipCodeResponse = response; _mainResponse.Success = true; return(_mainResponse); }
public MainResponse GetAllZipCodes(string city) { var zipCodes = _zipCodeRepository2.GetAll(x => x.City == city).OrderBy(x => x.ZipCode); var zipCodeResponse = _mapper.Map <List <GetZipCodes> >(zipCodes); ZipCodeResponse response = new ZipCodeResponse(); response.ZipCode = zipCodeResponse; _mainResponse.ZipCodeResponse = response; _mainResponse.Success = true; return(_mainResponse); }