//// GET api/values/5 //public Person Get(int id) //{ // using (LassiterEntities entity = new LassiterEntities()) // { // // entity.People pObj = new PersonEntity(); // return entity.People.Where(u => u.ID == id).FirstOrDefault(); // } //} private IList<Person> getPersons(int PostCode) { using (LassiterEntities entity = new LassiterEntities()) { // entity.People pObj = new PersonEntity(); if (PostCode == 0) { return entity.People.ToList(); } else { var postcodeLocation = (from p in entity.Postcodes where p.PostCode1 == PostCode select p).First().MapRef; if (postcodeLocation != null) { return (from pp in entity.People where pp.MapRef.Distance(postcodeLocation) < 5000 select pp).ToList(); } else { return null; } } } }
public IEnumerable<Postcode> Get(int pCode1 = 0) { using (LassiterEntities entity = new LassiterEntities()) if (pCode1 == 0) { return entity.Postcodes.ToList(); } else { var location = (from p in entity.Postcodes where p.PostCode1 == pCode1 select p).ToList(); return location; } }