using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TelephoneDirectoryService.Models;
namespace TelephoneDirectoryService.Controllers
{
    public class TestController : ApiController
    {
        ContactDBContext db = new ContactDBContext();


        [Route("api/test/{query}")]
        public IHttpActionResult GetPersons(String query)
        {
            var result = db.Persons.Where(p => p.FirstName.Contains(query));
            var persons = from person in result
                          select new {
                              firstName=person.FirstName,
                              lastName=person.LastName
                          };
            return Ok(persons);
        }
    }
}
