Soulsurv

Untitled

Dec 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Web.Http;
  7. using Services_1.Models;
  8. using System.IO;
  9.  
  10. namespace Services_1.Controllers
  11. {
  12. public class PersonController : ApiController
  13. {
  14. [Route("api/GetPerson")]
  15. public List<Person> GetPerson()
  16. {
  17.  
  18. StreamReader sr = new StreamReader("C:\\Users\\Toshino Kyouko\\Documents\\Visual Studio 2015\\Projects\\Services 1\\Services 1\\Mayflower.csv");
  19. string aLine = "";
  20. string[] anArray = new string[4];
  21. List<Person> aListOfPeople = new List<Person>();
  22. while (!sr.EndOfStream)
  23. {
  24. aLine = sr.ReadLine();
  25. anArray = aLine.Split(',');
  26.  
  27. Person aPerson = new Person();
  28. aPerson.ID = anArray[0];
  29. aPerson.LastName = anArray[1];
  30. aPerson.FirstName = anArray[2];
  31. aPerson.MiddleName = anArray[3];
  32. aListOfPeople.Add(aPerson);
  33. }
  34.  
  35.  
  36. sr.Close();
  37. return aListOfPeople;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment