public class PersonController : ApiController
{
Person[] persons = new Person[]
{
new Person {Id=0, FirstName="Петр", MiddleName="Петрович", LastName="Петров", Growth=24 },
new Person {Id=1, FirstName="Иван", MiddleName="Иванович", LastName="Иванов", Growth=20 }
};
public IEnumerable<Person> GetAllPersons()
{
return persons;
}
public IHttpActionResult GetProduct(int id)
{
var person = persons.FirstOrDefault((p) => p.Id == id);
if (person == null) return NotFound();
return Ok(person);
}
} |