Skip to content

Instantly share code, notes, and snippets.

@jonhilt
Created June 9, 2018 20:14
Show Gist options
  • Save jonhilt/92198511b60d99853698764768739039 to your computer and use it in GitHub Desktop.
Save jonhilt/92198511b60d99853698764768739039 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
namespace UsersAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class UserController : ControllerBase
{
[HttpGet]
public ActionResult<IEnumerable<User>> List()
{
// in real life - retrieve from database
var users = new List<User>{
new User {
Id = 1,
Name = "Jon Hilton",
Summary = "36 / Lead Software Developer" }
};
return Ok(users);
}
}
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Summary { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment