Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Web.Http;
- using Services_1.Models;
- using System.IO;
- namespace Services_1.Controllers
- {
- public class PersonController : ApiController
- {
- [Route("api/GetPerson")]
- public List<Person> GetPerson()
- {
- StreamReader sr = new StreamReader("C:\\Users\\Toshino Kyouko\\Documents\\Visual Studio 2015\\Projects\\Services 1\\Services 1\\Mayflower.csv");
- string aLine = "";
- string[] anArray = new string[4];
- List<Person> aListOfPeople = new List<Person>();
- while (!sr.EndOfStream)
- {
- aLine = sr.ReadLine();
- anArray = aLine.Split(',');
- Person aPerson = new Person();
- aPerson.ID = anArray[0];
- aPerson.LastName = anArray[1];
- aPerson.FirstName = anArray[2];
- aPerson.MiddleName = anArray[3];
- aListOfPeople.Add(aPerson);
- }
- sr.Close();
- return aListOfPeople;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment