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

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();
}
}
}