Skip to content

Instantly share code, notes, and snippets.

@yesez
Created May 6, 2013 03:12
Show Gist options
  • Save yesez/5523173 to your computer and use it in GitHub Desktop.
Save yesez/5523173 to your computer and use it in GitHub Desktop.
//IPaisRepository
public interface IPaisRepository
{
IEnumerable<Pais> GetAll();
}
//PaisRepository
public class PaisRepository:IPaisRepository
{
private readonly IEnumerable<Pais> paises = new List<Pais>()
{
new Pais() { Id = 1, Nombre = "Nicaragua" },
new Pais() { Id = 2, Nombre = "Colombia" },
new Pais() { Id = 3, Nombre = "España" },
new Pais() { Id = 4, Nombre = "Francia" },
new Pais() { Id = 5, Nombre = "Portugal" }
};
public IEnumerable<Pais> GetAll()
{
return paises.AsQueryable();
}
}
//PaisesSinDiController
public class PaisesSinDiController : ApiController
{
private readonly IPaisRepository repositorio = new PaisRepository();
public IEnumerable<Pais> Get()
{
return repositorio.GetAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment