|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using CountryProject.Models;
namespace CountryProject.Controllers
{
public class ContinentsController : ApiController
{
//GET /geography/continents
public IQueryable<Continent> Get()
{
return Geography.Continents.AsQueryable();
}
//GET /geography/continents/{id}
public Continent Get(string id)
{
Continent continent = Geography.Continents.Where(c => string.Compare(c.Name, id, true) == 0).Single();
return continent;
}
//GET /geography/continents/{continentID}/countries
public IQueryable<Country> GetCountries(string continentID)
{
Continent continent = Geography.Continents.Where(c => string.Compare(c.Name, continentID, true) == 0).Single();
return continent.Countries.AsQueryable();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been programming since 2004. Delphi, C, C++. Now I'm a big fan of C# and ASP MVC.