From 2f1bc54ecf20fe6ada5a0c940f6fa78fb28882d1 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Mon, 19 Oct 2020 22:24:27 -0400 Subject: [PATCH] create route --- Controllers/PeopleController.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Controllers/PeopleController.cs b/Controllers/PeopleController.cs index 3775bc8..7558d9e 100644 --- a/Controllers/PeopleController.cs +++ b/Controllers/PeopleController.cs @@ -56,5 +56,21 @@ namespace contacts.Controllers } } + + [HttpPost] + public Person[] Post([FromBody]Person newPerson) + { + using (var db = new PeopleContext()) + { + db.People.Add(newPerson); + db.SaveChanges(); + + var people = db.People + .OrderBy(person => person.PersonId) + .ToArray(); + return people; + + } + } } }