32 lines
1013 B
C#
32 lines
1013 B
C#
|
using POCDistance.Models;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace POCDistance.DAL
|
|||
|
{
|
|||
|
public class DataSourceAdapter : IDataSourceAdapter
|
|||
|
{
|
|||
|
public List<LocationModel> GetLocations()
|
|||
|
{
|
|||
|
IEnumerable<string> strLocations = File.ReadLines(@"DataSource/zip_to_lat_lon_North America.csv");
|
|||
|
var results = from str in strLocations
|
|||
|
.Skip(1)
|
|||
|
let tmp = str.Split(',')
|
|||
|
select new LocationModel()
|
|||
|
{
|
|||
|
ZipCode = tmp.ElementAt(1),
|
|||
|
City = tmp.ElementAt(2),
|
|||
|
State = tmp.ElementAt(3),
|
|||
|
Country = tmp.ElementAt(12),
|
|||
|
Latitude = tmp.ElementAt(9),
|
|||
|
Longitude = tmp.ElementAt(10)
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
return results.ToList();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|