public IActionResult Index() { var test = _context.People.Any(); if (test != true) { List <person> people = new List <person>(); string Line; StreamReader kartotek = new StreamReader(@"c:\test.csv"); while ((Line = kartotek.ReadLine()) != null) { var ting = Line.Split(new[] { ',' }); people.Add(new person { firstName = ting[1], lastName = ting[2], Email = ting[3], Gender = ting[4], ip_adress = ting[5] }); } foreach (var item in people) { _context.Add(item); } _context.SaveChanges(); } return(View()); }
public async Task <IActionResult> Create([Bind("id,firstName,lastName,Email,Gender,ip_adress")] person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }