Assignment for Location Calculation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1013 B

  1. using POCDistance.Models;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. namespace POCDistance.DAL
  6. {
  7. public class DataSourceAdapter : IDataSourceAdapter
  8. {
  9. public List<LocationModel> GetLocations()
  10. {
  11. IEnumerable<string> strLocations = File.ReadLines(@"DataSource/zip_to_lat_lon_North America.csv");
  12. var results = from str in strLocations
  13. .Skip(1)
  14. let tmp = str.Split(',')
  15. select new LocationModel()
  16. {
  17. ZipCode = tmp.ElementAt(1),
  18. City = tmp.ElementAt(2),
  19. State = tmp.ElementAt(3),
  20. Country = tmp.ElementAt(12),
  21. Latitude = tmp.ElementAt(9),
  22. Longitude = tmp.ElementAt(10)
  23. };
  24. return results.ToList();
  25. }
  26. }
  27. }